久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3556|回復: 13
打印 上一主題 下一主題
收起左側

PIC單片機存儲不足問題

[復制鏈接]
跳轉到指定樓層
樓主
ID:990881 發表于 2021-12-16 09:38 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
用的單片機型號為PIC12F1571,代碼大概300多行,刪掉一個調用的比較多的函數之后,能編譯成功,用的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空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:979299 發表于 2021-12-16 11:16 | 只看該作者
光刪除子函數不刪除主函數里的調用會報錯的,因為它找不到了,刪除了不能保證程序的完整性還能用嗎,只能精簡部份,或者用外部存儲,比如24C系列
回復

使用道具 舉報

板凳
ID:401564 發表于 2021-12-16 12:43 | 只看該作者
程序內存不夠你就刪除函數?那要這函數來干嘛?
難道你是復制別人的代碼嗎?
PIC的編譯環境很難搞,報錯的話,你很多時候是不會像Keil那樣能找到的
你只有嚴格按照C語言標準來寫
回復

使用道具 舉報

地板
ID:990881 發表于 2021-12-16 13:08 | 只看該作者
興安xa 發表于 2021-12-16 11:16
光刪除子函數不刪除主函數里的調用會報錯的,因為它找不到了,刪除了不能保證程序的完整性還能用嗎,只能精 ...

下面的報錯,我復制百度之后,是因為存儲不夠的原因,如果我不用那個調用的函數程序功能就實現不了了,精簡的話以我目前的水平已經到了極限了,代碼真的很簡單了,感謝您的建議,我會再去嘗試精簡代碼的
回復

使用道具 舉報

5#
ID:401564 發表于 2021-12-16 13:32 | 只看該作者
這個"CODE" 是怎么回事?不會是用了code來聲明了吧?
回復

使用道具 舉報

6#
ID:990881 發表于 2021-12-16 14:14 | 只看該作者
Y_G_G 發表于 2021-12-16 13:32
這個"CODE" 是怎么回事?不會是用了code來聲明了吧?

: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)



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

使用道具 舉報

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

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

使用道具 舉報

8#
ID:990881 發表于 2021-12-17 08:41 | 只看該作者
Y_G_G 發表于 2021-12-16 12:43
程序內存不夠你就刪除函數?那要這函數來干嘛?
難道你是復制別人的代碼嗎?
PIC的編譯環境很難搞,報錯的話, ...

我刪除函數是因為排除編譯器的問題,如果它什么都不寫也報這個錯誤呢,是吧?程序確實不是我寫的,我只是要改程序而已
回復

使用道具 舉報

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

分塊的,行我給弄一個文件里面
回復

使用道具 舉報

10#
ID:990881 發表于 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);
    }
}
回復

使用道具 舉報

11#
ID:415064 發表于 2021-12-17 09:45 | 只看該作者
就這么一點應該不至于
回復

使用道具 舉報

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

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

使用道具 舉報

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

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

使用道具 舉報

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

我把所有常數的乘除法運算算好之后,再寫入代碼,就可以編譯成功了,感謝大佬
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 亚洲视频免费观看 | 色婷婷九月 | 午夜免费成人 | 亚洲欧美一区二区三区在线 | 日韩欧美专区 | 天天操一操 | 91看片官网 | 91亚洲国产成人久久精品网站 | 韩日在线视频 | 久久婷婷色| 国产精品欧美一区二区三区 | 91麻豆产精品久久久久久夏晴子 | 久久久久久国产精品 | 一区二区三区四区不卡 | 免费看国产一级特黄aaaa大片 | 成人精品系列 | 久久伊人亚洲 | 99re6热在线精品视频播放 | 成人国产精品久久久 | 国产精品成人在线观看 | 成人黄页在线观看 | 中文字幕亚洲一区 | 国产综合精品一区二区三区 | 午夜视频网站 | 国产视频一区在线 | 国产精品精品久久久 | 免费精品视频 | 奇米四色影视 | 亚洲一区 | 亚洲精品视频导航 | 精品国产乱码久久久久久丨区2区 | 日韩免费高清视频 | 在线看无码的免费网站 | 伊人久久精品 | 欧美中文字幕在线观看 | 99久久精品免费 | 狠狠操狠狠操 | 久久精品国产清自在天天线 | 日韩精品视频在线观看一区二区三区 | 免费在线观看av网站 | 成年人在线 |