矩阵_串口通信.rar
(24.5 KB, 下载次数: 7)
#include "STC89C5xRC.h" typedef unsigned int u16; typedef unsigned int u8 ; unsigned char led_m ; extern void key_16(void); void UsartInit() { SCON=0x50; TMOD=0x20; PCON=0x80; TH1=0xF3; TL1=0xF3; ES=1; EA=1; TR1=1;
}
void delay_s(unsigned int t) { while(t--) { } }
void main() { UsartInit(); while(1) { key_16(); switch(led_m) { case'0':{P27=1;}break; case'1':{P27=0;}break;
case'S':{P27=!P27; delay_s(5000); }break; case'B':{P27=!P27; delay_s(5000); }break; //// case'Y': delay_s (50); {go();} break; //// case'X': delay_s (50); {hou();} break; } } }
void Usart() interrupt 4 { if(RI); { led_m=SBUF;
RI=0; SBUF=led_m; }
if(TI) { TI=0; } } //// void chuan() interrupt 4 //串口服务函数 ////{ //// RI=0; //软件清零 //// led_m=SBUF; //读取SBUF数据 //// }
|