根据MDK获知IAR选择即可,把他定义在main.c的main函数前面
#if 0?? ?//IAR printf USE #ifdef __GNUC__ #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #else #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #endif PUTCHAR_PROTOTYPE { HAL_UART_Transmit(&huart1 , (uint8_t *)&ch, 1, 100); return ch; } #endif
#if 1 ?//MDK printf USE #pragma import (__use_no_semihosting) struct __FILE { ?? ?int handle; }; FILE __stdout; void _sys_exit(int x) { ?? ?x=x; } int fputc(int ch, FILE *f) { ?? ?//while((USART1->SR&0x40)==0); ?? ?//USART1->DR = (uint8_t) ch; ?? ?HAL_UART_Transmit(&huart1 , (uint8_t *)&ch, 1, 100); ?? ?return ch; } #endif ?
如果用错有可能出现程序不运行的情况,debug要点几次才运行的情况
|