初级会员

- 积分
- 193
- 金钱
- 193
- 注册时间
- 2013-6-12
- 在线时间
- 16 小时
|
5金钱
代码是用原子大大开发板的代码调试,有时候少几个字符,还请帮忙指点指点,部分代码如下,还有调试过程如图片
以结尾0x0a 0x0d,还有定时的我都试过了,还是有相同的问题,
//void USART1_IRQHandler(void) //串口1中断服务程序
// {
// if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //接收中断(接收到的数据必须是0x0d 0x0a结尾)
// {
// rec_cmd =USART_ReceiveData(USART1);//(USART1->DR); //读取接收到的数据
// if(rec_cmd == 'r') Soft_Reset(); //重启单片机
// if((USART_RX_STA&0x8000)==0)//接收未完成
// {
// if(USART_RX_STA&0x4000)//接收到了0x0d
// {
// if(rec_cmd !=0x0a)USART_RX_STA=0;//接收错误,重新开始
// else USART_RX_STA|=0x8000; //接收完成了
// }
// else //还没收到0X0D
// {
// if(rec_cmd ==0x0d)USART_RX_STA|=0x4000;
// else
// {
// USART_RX_BUF[USART_RX_STA&0X3FFF]=rec_cmd;
// USART_RX_STA++;
// if(USART_RX_STA>(USART_REC_LEN-1))USART_RX_STA=0;//接收数据错误,重新开始接收
// }
// }
// }
// }
void USARTRes_string(void)
{ uint8_t len=0;
Test_Output_Config();
while(1)
{
if(USART_RX_STA&0x8000)
{
len=USART_RX_STA&0X7FFF;
USART_RX_BUF[len]=0;
if( strcmp( (const char*)USART_RX_BUF , "Station_1 Output1_Low Reset_Button") == 0 )
{
OUTPUT1_Low;
printf("\r\n Station_1 Output1_Low Reset_Button\r\n");//插入换行
}
if( memcmp( (char*)USART_RX_BUF , "Station_1 Output1_High Reset_Button",strlen("Station_1 Output1_High Reset_Button")) == 0 )
{
OUTPUT1_High;
printf ("\r\n Station_1 Output1_High Reset_Button\r\n");//插入换行
}
USART_RX_STA=0;
}
}
}
|
|