Need help
-
Hi, I doing a project using Atmel 89c51 and Keil for programming. In this, one module is to display a 4-digit number using seven segment display and a BCD decoder. I split the number in to separate digits using modulo and division operation. The first digit gets displayed correctly but the other digits are not displayed correctly. For eg: if my no is 0634 it gets displayed as 2704. This is the pseudo code int MilliSeconds=0; unsigned int Digit; unsigned int d1; int count=0; int choice=0; void InitStartTimer(void) { TCON=TCON & 0xCF; //clear timer0 flags TMOD=TMOD & 0xF9; //enable timer0 without changing timer1 setup TL0=0xC2; //Load the delay msb TH0=0xFB; //Load the delay lsb TR0=1; //start timer } void TimerIntr(void) interrupt 1 using 3 { TR0=0; if(count>=1) { P3_7=1; MilliSeconds+=1; } else count++; if(MilliSeconds==20) { switch(choice) { case 0: ch1=P1; ch2=P2&0x0F; Digit=(P2*256)+P1; d1=Digit % 10; Digit=Digit/10; d1=d1|0x10; P0=d1; choice++; break; case 1: d1=Digit%10; Digit=Digit/10; d1=d1|0x20; P0=d1; choice++; break; case 2: d1=Digit%10; Digit=Digit/10; d1=0; d1=d1|0x40; P0=d1; choice++; break; case 3: d1=Digit%10; Digit=Digit/10; d1=0; d1=d1|0x80; P0=d1; choice++; break; case 4: choice=0; break; } MilliSeconds=0; } InitStartTimer(); } The first digit gets displayed but after the division operation things get messy. Does divsion doesnot work in keil.I am a beginer. Expect ur help Thanks Cool Ju