新聞中心

        EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > IAR瑞薩單片機(jī)開(kāi)發(fā)加入printf調(diào)試函數(shù)

        IAR瑞薩單片機(jī)開(kāi)發(fā)加入printf調(diào)試函數(shù)

        作者: 時(shí)間:2016-11-20 來(lái)源:網(wǎng)絡(luò) 收藏
        IAR開(kāi)發(fā)環(huán)境,沒(méi)有printf函數(shù),自己百度加入了一個(gè)(http://www.cnblogs.com/codecamel/p/4686437.html),但是還是有一些問(wèn)題,特別是打印多個(gè)變量時(shí),只能夠打印字符串時(shí)比較穩(wěn)定,原因是因?yàn)関a_arg()給了錯(cuò)誤的返回值,故只能找尋其他的方法,今天測(cè)試了一下,新的辦法步驟如下

        1.關(guān)鍵之處,否則會(huì)出現(xiàn)PUTCHAR函數(shù)未定義現(xiàn)象。

        本文引用地址:http://www.104case.com/article/201611/318625.htm

        右鍵點(diǎn)擊工程選擇option->General Option->ibrary configuration中l(wèi)ibrary改為full,且General Option->library option->Printf formatter選項(xiàng)中選擇full2

        2. main.c中加入,其中使用的是串口1,注意如果提示FILE未定義,請(qǐng)?jiān)陬^文件最頂層添加#include

        1 /* Privatefunction prototypes --*/2 3 #ifdef __GNUC__4 /* With GCC/RAISONANCE, small printf(option LD Linker->Libraries->Small printf5   set to Yes) calls __io_putchar() */6 #define PUTCHAR_PROTOTYPE int__io_putchar(int ch)7 #else8 #define PUTCHAR_PROTOTYPE int fputc(int ch,FILE *f)9 #endif /* __GNUC__ */10 11 /**12   *@brief  Retargets the C library printffunction to the USART.13   *@param  None14   *@retval None15   */16 PUTCHAR_PROTOTYPE17 {18   /*Place your implementation of fputc here */19   /*e.g. write a character to the USART */20  USART_SendData(EVAL_COM1, (uint8_t) ch);21   /*Loop until the end of transmission */22  while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET);23  return ch;24 }

        printf函數(shù)打印字符串,遇到

        主站蜘蛛池模板: 密云县| 霍林郭勒市| 晋宁县| 海淀区| 聂荣县| 上虞市| 府谷县| 永吉县| 安顺市| 拉萨市| 原平市| 马鞍山市| 西安市| 宁波市| 颍上县| 凯里市| 罗平县| 宁陕县| 平武县| 上高县| 青岛市| 高邮市| 武乡县| 横山县| 信宜市| 乌拉特中旗| 开封县| 班玛县| 通江县| 静安区| 松桃| 舞钢市| 台北县| 浏阳市| 吉木萨尔县| 江安县| 温泉县| 锦州市| 黄浦区| 荆州市| 荆门市|