我把您的usart.c文件做了下面改动,为了方便调试,结果不能用串口助手发送
[mw_shl_code=c,true] int main(void)
{
uint8_t t;
delay_init(); //延时函数初始化
uart_init(9600);
NVIC_Configuration();
while(1)
{
// printf("ok");
// delay_ms(1000);
}
}
[/mw_shl_code]
[mw_shl_code=c,true]在usart.c中做的修改
void Uart1_Putchar(u8 ch)
{
USART_SendData(USART1,(u8)ch);
while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET);
}
void USART1_IRQHandler(void) //串口1中断服务程序
{
u8 Res;
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //接收中断(接收到的数据必须是0x0d 0x0a结尾)
{
Res =USART_ReceiveData(USART1);//(USART1->DR); //读取接收到的数据
if(Res==0)
{
Res=0;
Uart1_Putchar(1);
Uart1_Putchar(0);
}
}
}
[/mw_shl_code]
怎么用串口助手发送啊原子哥?非常感谢
|