Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <REGX52.H>
- unsigned char xdata Lewy _at_ 0xFE00;
- unsigned char xdata Prawy _at_ 0xFD00;
- void init(void);
- //Uklad 2 wyswietlacz
- //1111 1110 0000 0000 - lewy wyswietlacz -> 0xFE00
- //1111 1101 0000 0000 - prawy wyswietlacz -> 0xFD00
- unsigned char code tab[] = { 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};
- int l = 0;
- int p = 0;
- int a = 0;
- void ISR_INT0(void) interrupt 0
- {
- if(a == 0)
- {
- a = 1;
- }
- else
- {
- a = 0;
- }
- }
- void Timer(void) interrupt 1
- {
- TH0 = 0x8F;
- TL0 = 0x7F;
- TF0 = 0;
- if(a == 0)
- {
- p++;
- if(p == 10)
- {
- p = 0;
- l++;
- if(l == 10)
- {
- p=9;
- l=9;
- }
- }
- }
- else
- {
- p--;
- if(p == -1)
- {
- p = 9;
- l--;
- if(l == -1)
- {
- p=0;
- l=0;
- }
- }
- }
- }
- void main(void)
- {
- init();
- for(;;)
- {
- Lewy = tab[l];
- Prawy =tab [p];
- }
- }
- void init(void)
- {
- TMOD = 0x01;
- TH0 = 0x8F;
- TL0 = 0x7F;
- ET0 = 1;
- EX0 = 1;
- IT0 = 1;
- EA = 1;
- TR0 = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement