通过对串口下发指令,来操作数码管,但是发现通讯可以,数码管就是不亮,求解释!!!! #include <reg52.h> uchar codetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; uint datbuf; sbit beep = P3^5; bit flag; void delay_ms(uchar t) { uchari; for(;t>0;t--) for(i=110;i>0;i--); } void Display() { uchari; P2= 0x00; for(i=0;i<16;i++) { P0= ~table; delay_ms(2000); } } void uart_init() { TMOD&=0x0F; TMOD|=0x20; SCON= 0x50; TH1= 0xFD; TL1= 0xFD; EA= 1; ES= 1; TR1= 1; } void main() { uart_init(); while(1) { if(flag) { ES= 0; flag= 0; if(datbuf == '1') { Display(); } SBUF = datbuf; while(!TI); TI= 0; ES= 1; } } } void uart_isr() interrupt 4 { RI= 0; datbuf= SBUF; flag= 1; }
/*********************** 原理图见附件! ************************/
|