完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
想用N76E003识别电脑的串口指令OPEN、CLOSE,作出LED-P12灯亮灭的响应目前用BSP里面的源码,只收正常收到电脑发过来的一个字节,超过一个字节就乱码了
#include #include "N76E003.h" #include "SFR_Macro.h" #include "Common.h" #include "Delay.h" #include "Function_Define.h" #define BUFFER_SIZE 16 UINT8 UART_BUFFER[BUFFER_SIZE],temp; UINT16 u16CNT=0,u16CNT1=0; bit riflag; /** * FUNCTION_PURPOSE: serial interrupt, echo received data. * FUNCTION_INPUTS: P3.0(RXD) serial input * FUNCTION_OUTPUTS: P3.1(TXD) serial output */ void serial_IT(void) interrupt 4 { if (RI) { /* if reception occur */ clr_RI; /* clear reception flag for next reception */ UART_BUFFER[u16CNT] = SBUF; u16CNT ++; riflag =1; } if(TI) { clr_TI; /* if emission occur */ } } /************************************************************************************************************ * Main function ************************************************************************************************************/ void main (void) { P06_Quasi_Mode; //Set UART GPIO are Quasi Mode P07_Quasi_Mode; InitialUART0_Timer1(115200); /* 115200 Baud Rate from timer1*/ SCON = 0xD2; // Special setting the mode 3 set_ES; //enable UART interrupt set_EA; //enable global interrupt clr_TB8; Send_Data_To_UART0(0x53); //Send "start" ascii code show reset initial status Send_Data_To_UART0(0x74); Send_Data_To_UART0(0x61); Send_Data_To_UART0(0x72); Send_Data_To_UART0(0x74); while(1) { if (riflag) { temp = SBUF; //This part send the receive data from RXD to TXD Send_Data_To_UART0(temp); riflag = 0; } } } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-10 17:50 , Processed in 0.379955 second(s), Total 43, Slave 38 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号