1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| #include <Key.h> #include <Nixie.h> #include <LED.h> #include <Init.h> #include <Uart.h> #include <INTRINS.H>
unsigned char Nixie_Buf[8]={10,10,10,10,10,10,10,10}; unsigned char Nixie_Pos; unsigned char Nixie_Point[8]={0,0,0,0,0,0,0,0};
unsigned char Key; unsigned char Key_Up,Key_Down,Key_Val,Key_Old; unsigned char ucLED[8]={0,0,0,0,0,0,0,0};
unsigned int Nixie_Timer; unsigned int Key_Timer;
void Key_Proc(void) { if(Key_Timer) return; Key_Timer=1; Key_Val=Key_Read(); Key_Down=Key_Val & (Key_Old ^ Key_Val); Key_Up=~Key_Val & (Key_Old ^ Key_Val); Key_Old=Key_Val; }
void Nixie_Proc(void) { if(Nixie_Timer) return; Nixie_Timer=1; }
void LED_Proc(void) { }
void Timer0_Init(void) { AUXR &= 0x7F; TMOD &= 0xF0; TL0 = 0x18; TH0 = 0xFC; TF0 = 0; TR0 = 1; ET0 = 1; EA = 1; }
void Delay500ms(void) { unsigned char data i, j, k;
_nop_(); _nop_(); i = 23; j = 205; k = 120; do { do { while (--k); } while (--j); } while (--i); }
void main() { Timer0_Init(); System_Init(); Uart1_Init(); Delay500ms(); Uart1_SendString("Hello UART"); while(1) {
} }
void Timer0_Server(void) interrupt 1 { if(++Nixie_Timer==500){Nixie_Timer=0;} if(++Key_Timer==20){Key_Timer=0;} if(++Nixie_Pos==8){Nixie_Pos=0;} Nixie_Disp(Nixie_Pos,Nixie_Buf[Nixie_Pos],Nixie_Point[Nixie_Pos]); LED_Disp(Nixie_Pos,ucLED[Nixie_Pos]); }
|