No.102598 作者:wangxd5429 邮件:wangxd5429@sohu.com ID:30288 登陆:55次 文章数:56篇 最后登陆IP:211.103.220.197 最后登陆:2017/1/4 14:21:50 注册:2005/1/21 11:46:15 财富:452 发帖时间:2014/12/3 9:56:49 发贴者IP:61.148.243.245 标题:wangxd5429:[求助]关于AVR单片机的问题4 摘要:No.102598[求助]关于AVR单片机的问题4 各位高手,小弟正在基于AVR开发一款智能小车,遇到“串口接收字符串错误”,调试了一下,发现当屏蔽了端口B后,可以正常显示,对端口B赋值后,无法正常显示。请教其中的原因。谢谢。部分代码如下: void main(void) { int counter = 0; int i; int stop_count = 0; MCUCSR |= BIT(7); MCUCSR |= BIT(7); vInitEeprom(); uart0_init(); init_devices(); EECR |= BIT(EERIE); DUTY1=50; DUTY2=50; LCD_write_string(0,0,dis1); LCD_write_string(0,1,"SPACE:"); memcpy (ControlMsg , "stop" , 4); addr = 1; while(1) { //str_send (Xunji); if (Xunji == 1) { //rcv_new = 0; //str_send ('x'); stop_count = 0; forward(); //delay_nms(10); if(L_XJ == 0 || R_XJ == 0) { break; } } else if (Xunji == 0) { //rcv_new = 0; //str_send ('c'); if (stop_count == 0) { //str_send ('c'); stop(); stop_count++; } } } while(1) { if (Xunji == 1) { //rcv_new = 0; stop_count = 0; switch (PINB&0x03) { case 0x03: DUTY1 = 35; DUTY2 = 35; //str_send ('a'); forward(); break; case 0x00: DUTY1 = 35; DUTY2 = 35; //str_send ('b'); forward(); break; case 0x02: for (i = 0 ; i < 5 ; i++) { if ((PINB&0x03) == 0x02) { counter++; } else if ((counter > = 0)&&(counter < 5)&&((PINB&0x03) == 0x03)) { break; } } if (counter == 5) { counter = 0; DUTY1 = 40; ......
>>返回讨论的主题
|