#include<reg51.h> #include <intrins.h> #define uint8 unsigned char #define uint16 unsigned int uint8 receive_buffer; led=0xfe; void send(uint8 moshi) { SBUF=moshi; while(!TI); TI=0; } void main() { P2 = 0xff; TMOD = 0x20; TH1 = 0xfd; TL1 = 0xfd; TR1 = 1; EA = 1; SM0 = 0; SM1 = 1; REN = 1; ES = 1; while(1) { P2 =_crol_(led,(receive_buffer-1)); send(receive_buffer); } } void uart_int() interrupt 4 { if(RI == 1) { RI = 0; receive_buffer = SBUF; } }
|