找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

帖子
查看: 3601|回復(fù): 13
打印 上一主題 下一主題
收起左側(cè)

PIC單片機(jī)存儲(chǔ)不足問(wèn)題

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:990881 發(fā)表于 2021-12-16 09:38 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
用的單片機(jī)型號(hào)為PIC12F1571,代碼大概300多行,刪掉一個(gè)調(diào)用的比較多的函數(shù)之后,能編譯成功,用的MPLAB X IDE5.05,XC8(v2.30)


interrupt_manager.c:52:: warning: (1421) ignoring argument "high_priority" used by "__interrupt" attribute/specifier
:0:: error: (1347) can't find 0x13 words (0x13 withtotal) for psect "text16" in class "CODE" (largest unused contiguous range 0xA)
Non line specific message::: advisory: (1493) updated 32-bit floating-point routines might trigger "can't find space" messages appearing after updating to this release; consider using the smaller 24-bit floating-point types
:0:: error: (1347) can't find 0x10 words (0x10 withtotal) for psect "text20" in class "CODE" (largest unused contiguous range 0xA)
:0:: error: (1347) can't find 0x9 words (0x9 withtotal) for psect "text18" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x8 words (0x8 withtotal) for psect "text15" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x7 words (0x7 withtotal) for psect "text17" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x6 words (0x6 withtotal) for psect "text14" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x4 words (0x4 withtotal) for psect "text12" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x3 words (0x3 withtotal) for psect "text8" in class "CODE" (largest unused contiguous range 0x1)

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:979299 發(fā)表于 2021-12-16 11:16 | 只看該作者
光刪除子函數(shù)不刪除主函數(shù)里的調(diào)用會(huì)報(bào)錯(cuò)的,因?yàn)樗也坏搅�,刪除了不能保證程序的完整性還能用嗎,只能精簡(jiǎn)部份,或者用外部存儲(chǔ),比如24C系列
回復(fù)

使用道具 舉報(bào)

板凳
ID:401564 發(fā)表于 2021-12-16 12:43 | 只看該作者
程序內(nèi)存不夠你就刪除函數(shù)?那要這函數(shù)來(lái)干嘛?
難道你是復(fù)制別人的代碼嗎?
PIC的編譯環(huán)境很難搞,報(bào)錯(cuò)的話,你很多時(shí)候是不會(huì)像Keil那樣能找到的
你只有嚴(yán)格按照C語(yǔ)言標(biāo)準(zhǔn)來(lái)寫(xiě)
回復(fù)

使用道具 舉報(bào)

地板
ID:990881 發(fā)表于 2021-12-16 13:08 | 只看該作者
興安xa 發(fā)表于 2021-12-16 11:16
光刪除子函數(shù)不刪除主函數(shù)里的調(diào)用會(huì)報(bào)錯(cuò)的,因?yàn)樗也坏搅�,刪除了不能保證程序的完整性還能用嗎,只能精 ...

下面的報(bào)錯(cuò),我復(fù)制百度之后,是因?yàn)榇鎯?chǔ)不夠的原因,如果我不用那個(gè)調(diào)用的函數(shù)程序功能就實(shí)現(xiàn)不了了,精簡(jiǎn)的話以我目前的水平已經(jīng)到了極限了,代碼真的很簡(jiǎn)單了,感謝您的建議,我會(huì)再去嘗試精簡(jiǎn)代碼的
回復(fù)

使用道具 舉報(bào)

5#
ID:401564 發(fā)表于 2021-12-16 13:32 | 只看該作者
這個(gè)"CODE" 是怎么回事?不會(huì)是用了code來(lái)聲明了吧?
回復(fù)

使用道具 舉報(bào)

6#
ID:990881 發(fā)表于 2021-12-16 14:14 | 只看該作者
Y_G_G 發(fā)表于 2021-12-16 13:32
這個(gè)"CODE" 是怎么回事?不會(huì)是用了code來(lái)聲明了吧?

:0:: error: (1347) can't find 0x10 words (0x10 withtotal) for psect "text20" in class "CODE" (largest unused contiguous range 0xA)
:0:: error: (1347) can't find 0x9 words (0x9 withtotal) for psect "text18" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x8 words (0x8 withtotal) for psect "text15" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x7 words (0x7 withtotal) for psect "text17" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x6 words (0x6 withtotal) for psect "text14" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x4 words (0x4 withtotal) for psect "text12" in class "CODE" (largest unused contiguous range 0x1)
:0:: error: (1347) can't find 0x3 words (0x3 withtotal) for psect "text8" in class "CODE" (largest unused contiguous range 0x1)



這些錯(cuò)誤表示ROM (=閃存)內(nèi)存不足。
這意味著正在使用的 PIC 的代碼太多
回復(fù)

使用道具 舉報(bào)

7#
ID:401564 發(fā)表于 2021-12-16 14:52 | 只看該作者
東方木青龍 發(fā)表于 2021-12-16 14:14
:0:: error: (1347) can't find 0x10 words (0x10 withtotal) for psect "text20" in class "CODE" (larg ...

搞半天咋就不把代碼文件上傳呢,我去運(yùn)行試一下
回復(fù)

使用道具 舉報(bào)

8#
ID:990881 發(fā)表于 2021-12-17 08:41 | 只看該作者
Y_G_G 發(fā)表于 2021-12-16 12:43
程序內(nèi)存不夠你就刪除函數(shù)?那要這函數(shù)來(lái)干嘛?
難道你是復(fù)制別人的代碼嗎?
PIC的編譯環(huán)境很難搞,報(bào)錯(cuò)的話, ...

我刪除函數(shù)是因?yàn)榕懦幾g器的問(wèn)題,如果它什么都不寫(xiě)也報(bào)這個(gè)錯(cuò)誤呢,是吧?程序確實(shí)不是我寫(xiě)的,我只是要改程序而已
回復(fù)

使用道具 舉報(bào)

9#
ID:990881 發(fā)表于 2021-12-17 08:42 | 只看該作者
Y_G_G 發(fā)表于 2021-12-16 14:52
搞半天咋就不把代碼文件上傳呢,我去運(yùn)行試一下

分塊的,行我給弄一個(gè)文件里面
回復(fù)

使用道具 舉報(bào)

10#
ID:990881 發(fā)表于 2021-12-17 08:58 | 只看該作者
#pragma config FOSC = INTOSC    // ->INTOSC oscillator; I/O function on CLKIN pin
#pragma config WDTE = ON    // Watchdog Timer Enable->WDT enabled
#pragma config PWRTE = OFF    // Power-up Timer Enable->PWRT disabled
#pragma config MCLRE = ON    // MCLR Pin Function Select->MCLR/VPP pin function is MCLR
#pragma config CP = OFF    // Flash Program Memory Code Protection->Program memory code protection is disabled
#pragma config BOREN = ON    // Brown-out Reset Enable->Brown-out Reset enabled
#pragma config CLKOUTEN = OFF    // Clock Out Enable->CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin

// CONFIG2
#pragma config WRT = OFF    // Flash Memory Self-Write Protection->Write protection off
#pragma config PLLEN = OFF    // PLL Enable->4x PLL disabled
#pragma config STVREN = ON    // Stack Overflow/Underflow Reset Enable->Stack Overflow or Underflow will cause a Reset
#pragma config BORV = LO    // Brown-out Reset Voltage Selection->Brown-out Reset Voltage (Vbor), low trip point selected.
#pragma config LPBOREN = OFF    // Low Power Brown-out Reset enable bit->LPBOR is disabled
#pragma config LVP = ON    // Low-Voltage Programming Enable->Low-voltage programming enabled

#include <xc.h>
//1. big board vishy mos
//2. small board Ao mos
#include "mcc.h"
static uint16_t adc_data=0;
static uint8_t adc_voltage=0;
static uint16_t pwm_data0=0;
static uint16_t power_data=0;
static uint16_t power_voltage=0;


uint16_t timer_100ms_flag=0;
uint8_t timer_10ms_flag=0;



void delay_proces (uint32_t delaytime)
{
     uint32_t cnt;
     cnt=delaytime;
     while(cnt--)
     {
          CLRWDT();
     }
}
void adc_process(void)
{
    uint16_t k;
    uint8_t i;
    k=0;
    for (i=0;i<16;i++)
    {
     k+=ADC1_GetConversion(3);
      CLRWDT();
         NOP();NOP();NOP();NOP();NOP();NOP();NOP();   
    }
   adc_data = k >> 4;
}
void power_process(void)
{
    uint32_t kk;
    kk = (uint32_t)adc_data * (uint32_t)33 * (uint32_t)25 * (uint32_t)10 / (uint32_t)1024;
    power_voltage = (uint16_t)(kk+80) / 10;
}


void get_pwm_data(void)
{
    uint32_t kk;//,kkm;
    if(timer_100ms_flag < 50)
    {
        kk = (uint32_t)((uint32_t)58 * (uint32_t)799);
        kk = ((uint32_t)kk / (uint32_t)power_voltage);
        //kk=((uint32_t)kk*(uint32_t)20/(uint32_t)10)+((uint32_t)power_voltage/90); //34W
        kk = ((uint32_t)kk * (uint32_t)16 / (uint32_t)10) + ((uint32_t)power_voltage / 90); //34W
        pwm_data0 = (uint16_t)kk + 2;  
        if( pwm_data0 > 799 )
        {
            pwm_data0 = 800;                     //full power pwm
        }
        if(power_voltage < 70)
        {           
           pwm_data0 = 0;
           kk = (power_voltage & 0x0f);
           delay_proces(kk * 16667);
           timer_100ms_flag = 0;
        }
        else if(power_voltage < 120)
        {
            pwm_data0 = 800;                           //full power pwm
        }
    }         
    else
    {     
        kk = (uint32_t)((uint32_t)131 * (uint32_t)799);
        kk = ((uint32_t)kk / (uint32_t)power_voltage) * (uint32_t)23 / (uint32_t)100 * (uint32_t) 2;
        if(power_voltage < 50)
        {
            if(timer_10ms_flag > 6)
            {
               PWM3_DutyCycleSet(0);
            }
        }
        else
        {
            timer_10ms_flag = 0;
            if( power_voltage < 122)
             {
                 kk = kk + 3 + 2 + 2;
             }  
            else if( power_voltage < 160)
            {
                kk = kk + 2 + 2;
            }
            else if( power_voltage < 246)
            {
                kk = kk + 2;
            }
            else if(power_voltage > 460 && power_voltage < 730)
            {
                kk = kk + 4;
            }
            else if(power_voltage >= 730)
            {
                pwm_data0=0;
            }  
            pwm_data0=kk+9;                                                        //?????????????
            if(pwm_data0>799)
            {
               pwm_data0=800;                       //full power pwm
            }
        }   
    }
}
void main(void)
{
    SYSTEM_Initialize();
    INTERRUPT_GlobalInterruptEnable();
    INTERRUPT_PeripheralInterruptEnable();

    while((power_voltage < 84) || (power_voltage > 730))
    {
      adc_process();                          //gather 16 adc-data,get the average
      PWM3_DutyCycleSet(pwm_data0);                        //get the power_voltage
      CLRWDT();
    }
    timer_100ms_flag = 0;
    while(timer_100ms_flag < 2)
    {
        CLRWDT();
    }
     //timer_2ms_flag=1;
    timer_100ms_flag = 0;
    while (1)
    {
        CLRWDT();  
        adc_process();
        power_process();
        get_pwm_data();
        PWM3_DutyCycleSet(pwm_data0);
    }
}
回復(fù)

使用道具 舉報(bào)

11#
ID:415064 發(fā)表于 2021-12-17 09:45 | 只看該作者
就這么一點(diǎn)應(yīng)該不至于
回復(fù)

使用道具 舉報(bào)

12#
ID:962286 發(fā)表于 2021-12-17 09:54 | 只看該作者
東方木青龍 發(fā)表于 2021-12-17 08:58
#pragma config FOSC = INTOSC    // ->INTOSC oscillator; I/O function on CLKIN pin
#pragma config WD ...

PIC12F1571這顆料沒(méi)有硬件乘法器,你代碼中有一大堆大字節(jié)變量乘除法,非常占空間;另外你的XC8是不是lite模式的?
回復(fù)

使用道具 舉報(bào)

13#
ID:990881 發(fā)表于 2021-12-17 16:44 | 只看該作者
MCU_FANS 發(fā)表于 2021-12-17 09:54
PIC12F1571這顆料沒(méi)有硬件乘法器,你代碼中有一大堆大字節(jié)變量乘除法,非常占空間;另外你的XC8是不是lit ...

沒(méi)錯(cuò),是這個(gè)原因
我將void get_pwm_data(void)函數(shù)中的大字節(jié)變量乘除法屏蔽之后,編譯能通過(guò)
/*  kk = ((uint32_t)kk / (uint32_t)power_voltage);
      
        kk = ((uint32_t)kk * (uint32_t)16 / (uint32_t)10) + ((uint32_t)power_voltage / 90); //34W
      */
回復(fù)

使用道具 舉報(bào)

14#
ID:990881 發(fā)表于 2021-12-17 16:54 | 只看該作者
MCU_FANS 發(fā)表于 2021-12-17 09:54
PIC12F1571這顆料沒(méi)有硬件乘法器,你代碼中有一大堆大字節(jié)變量乘除法,非常占空間;另外你的XC8是不是lit ...

我把所有常數(shù)的乘除法運(yùn)算算好之后,再寫(xiě)入代碼,就可以編譯成功了,感謝大佬
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表