中级会员
 
- 积分
- 279
- 金钱
- 279
- 注册时间
- 2015-10-5
- 在线时间
- 27 小时
|
发表于 2016-3-24 13:07:05
|
显示全部楼层
使用printf是要进行重定向的,要加上这两段
/* Private function prototypes -----------------------------------------------*/
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/**
* @brief Retargets the C library printf function to the USART.
* @param None
* @retval None
*/
PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here */
/* e.g. write a character to the USART */
USART_SendData(USART2, (uint8_t) ch);
/* Loop until the end of transmission */
while (USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET)
{}
return ch;
}
上面的两个USART2要进行相应的修改就可以了
然后卡在B处有可能是你开了相应的中断而没有清中断的标志位,卡在中断服务函数里面了,再仔细查查是什么回事吧
|
|