调试uIP出现死机问题

在调试uIP,加入http功能时,调试出现死循环
调试uIP出现死机问题_第1张图片
原因是所加入的http文件中含有printf等输出函数,遇到这种情况,有2种解决方法:
1.Keil中勾选“Use MicroLIB”
2.

//加入以下代码,支持printf函数,而不需要选择Use MicroLIB
#if 1
#pragma import(__use_no_semihosting) 
//标准库需要支持的函数
struct __FILE 
{ 
    int handle; 
}; 
FILE __stdout;       
//定义_sys_exit()以避免使用半主机模式
_sys_exit(int x) 
{ 
    x = x; 
} 
//重定义fputc函数
int fputc(int ch, FILE *f)
{      
    while((USART1->SR&0X40)==0);//循环发送,直到发送完毕
    USART1->DR = (u8) ch;      
    return ch;
}
#endif

你可能感兴趣的:(printf,调试,死循环)