這邊用LwIP_UDPTCP_Echo_Server_Netconn_RTOS這個範例和uVision來修改
1. 打開專案後進到Options for Target設定
2. 把main.h裡面的#define USE_LCD這行Comment掉
//#define USE_LCD
3. 把lcd_log.c裡面的LCD_LOG_PUTCHAR整段Comment掉
4. 把lcd_log_conf.h裡面Redirect the printf to the LCD下面那段整段Comment掉
4. 把lcd_log_conf.h裡面Redirect the printf to the LCD下面那段整段Comment掉
///* Redirect the printf to the LCD */ //#ifdef __GNUC__ ///* With GCC, small printf (option LD Linker->Libraries->Small printf // set to 'Yes') calls __io_putchar() */ //#define LCD_LOG_PUTCHAR int __io_putchar(int ch) //#else //#define LCD_LOG_PUTCHAR int fputc(int ch, FILE *f) //#endif /* __GNUC__ */
5. 接著一樣在lcd_log_conf.h裡面加入以下程式
#define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n))) #define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n))) #define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n))) #define DEMCR (*((volatile unsigned long *)(0xE000EDFC))) #define TRCENA 0x01000000 struct __FILE { int handle;}; FILE __stdout; FILE __stdin; int fputc(int ch, FILE *f) { if (DEMCR & TRCENA) { while (ITM_Port32(0) == 0); ITM_Port8(0) = ch; } return(ch); }
6. 在main.c的SystemClock_Config後面加入debug訊息
printf(" test\n\r");
7. Rebuild後接著Ctrl + F5進入Debug
8. 進入Debug後打開Debug viewer
單步執行到加入printf的地方就能看到訊息輸出在右邊的Debug viewer視窗
沒有留言:
張貼留言