找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 6016|回復(fù): 1
收起左側(cè)

xc8編譯器,pic16f1825 單片機(jī) 串口發(fā)送程序編譯不過.

[復(fù)制鏈接]
ID:248855 發(fā)表于 2017-11-13 10:45 | 顯示全部樓層 |閱讀模式
大家好!請教個問題:
    xc8編譯器,pic16f1825 單片機(jī) 串口發(fā)送程序編譯不過.代碼如下:
/串口發(fā)送一串字符
void EUSART_SendString(const unsigned char  *pData)
{   
    di(); //GIE = 0 //disable all interrupts
    TXIE =0;  //屏閉EUSART 發(fā)送中斷
   
    int len = strlen(pData);
    unsigned char  *str= malloc(len);
    if(str !=NULL){
        strcpy(str,pData);
        while(*str!='\0')
        {
            TXREG = *str++;
            while(TXSTAbits.TRMT==0);//TRMT=1時,TSR為空,否則不為空
        }
        free(str);
    }
}

編譯錯誤 如下:
:: warning: (1273) Omniscient Code Generation not available in Free mode
mcu_wifi.c:108: advisory: (1510) non-reentrant function "_EUSART_SendString" appears in multiple call graphs and has been duplicated by the compiler
C:\Program Files\Microchip\xc8\v1.42\sources\common\strcpy.c:8: advisory: (1510) non-reentrant function "_strcpy" appears in multiple call graphs and has been duplicated by the compiler
C:\Program Files\Microchip\xc8\v1.42\sources\common\strlen.c:4: advisory: (1510) non-reentrant function "_strlen" appears in multiple call graphs and has been duplicated by the compiler
uart_comm.c:9: warning: (520) function "_calc_checksum" is never called
:0: error: (500) undefined symbols:
        _free(dist/default/production\mcu_wifi.X.production.obj) _malloc(dist/default/production\mcu_wifi.X.production.obj)
(908) exit status = 1
nbproject/Makefile-default.mk:147: recipe for target 'dist/default/production/mcu_wifi.X.production.hex' failed
make[2]: Leaving directory 'D:/VM/share/AbleCloud/mcu_firmware/mcu_wifi/mcu_wifi.X'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/VM/share/AbleCloud/mcu_firmware/mcu_wifi/mcu_wifi.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [dist/default/production/mcu_wifi.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

編譯已失敗 (退出值2, 總時間: 2s)

各位大牛,請幫我看下是什么問題!!
回復(fù)

使用道具 舉報

ID:869731 發(fā)表于 2020-12-31 15:49 | 顯示全部樓層
你的free 沒有包含頭文件 free 的頭文件是 #include<stdlib.h>
回復(fù)

使用道具 舉報

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

本版積分規(guī)則

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

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

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