s.k.sahoo
Junior Member level 1
Hi Masters,
I have written a code for 4 digit 7Seg display counter. There is some error in my code, when i simulate in Proteus 4th, 3rd and 2nd display is not showing Zero (0). Please help.
Code:
I have written a code for 4 digit 7Seg display counter. There is some error in my code, when i simulate in Proteus 4th, 3rd and 2nd display is not showing Zero (0). Please help.
Code:
Code C - [expand] 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 #include <reg52.h> #define uchar unsigned char #define uint unsigned int sbit clear = P3^4; uchar code DSY_CODE[]= { 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff }; uchar code Scan_BITs[]= { 0x20,0x10,0x08,0x04,0x02,0x01 }; uchar data Buffer_Counts[]={0,0,0,0,0,0}; uint Count=0; void DelayMS(uint x) { uchar t; while(x--) { for(t=0;t<120;t++); } } void Show_Counts() { uint i; Buffer_Counts[3] = Count / 1000; Buffer_Counts[2] = Count % 1000 / 100; Buffer_Counts[1] = Count % 100 / 10; Buffer_Counts[0] = Count % 10; if(Buffer_Counts[3]==0) { Buffer_Counts[3] = 0x0a; } if(Buffer_Counts[2]==0) { Buffer_Counts[2]=0x0a; } if(Buffer_Counts[1]==0) { Buffer_Counts[1]=0x0a; } for(i=0;i<4;i++) { P2 = Scan_BITs[i]; P1 = DSY_CODE[Buffer_Counts[i]]; DelayMS(1); } } void main() { IT0 = 1; IE = 0x81; while(1) { if(clear == 0) Count = 0; Show_Counts(); } } void EX_INT0() interrupt 0 { Count++; }
Attachments
Last edited by a moderator: