本人在学习51
单片机中,在学习串口
通信时,想利用某个软件,向单片机发送某个特定的字符后控制LED灯的状态
但是在发送和接受到的数据都是正常的情况下,却不能控制LED灯的状态,求解!!
代码如下:
[C]
纯文本查看 复制代码
#include
typedef unsigned char u8 ;typedef unsigned int u16 ;***it LED = P0^0 ;u8 temp ;void Usart_config (){ TMOD = 0x20 ; TH1 = 0xf3 ; TL1 = 0xf3 ; TR1 = 1 ; SCON = 0x50 ; PCON = 0x80 ; ES = 1 ; EA = 1 ; } void main (){ Usart_config () ; LED = 0 ; while ( 1 ) { switch ( temp ) { case ( 1 ) : LED = ~LED ; temp = 0 ; break ; } }}void Usart () interrupt 4 { u8 receiveData ; receiveData = SBUF ; temp = receiveData ; RI = 0 ; SBUF = receiveData ; while ( !ti ) ; TI = 0 ; }