0killingsoul0
Junior Member level 2
View attachment one.bmpHi all. I am getting a weird type of error.Its a simle code to count the interrupts in ten second. When i physically implement the circuit on bread board , its counting more low level signals ( grounding the pin 3.2) . Like if i ground it once it should count/display one but its displaying larger value. This code is working perfectly on proteus and on trainer kit. But dont know what i am missing in circuit its not working.
View attachment one.bmp
View attachment one.rar
View attachment one.bmp
View attachment one.rar
Code:
// Program to interface single seven segment
#include<reg51.h>
char num[]={0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10}; // Hex values corresponding to digits 0 to 9
unsigned int counter;
unsigned int counter1;
unsigned int counter2;
unsigned int counter3;
unsigned int counter4;
delay_ms(int time) // Time delay function
{
int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
////////////// iNTERUPT tO cOUNT
void ex0_isr (void) interrupt 0
{
counter++; // Increment the count
}
void countdelay(void)
{
TMOD=0x01;
TL0=0x00;
TH0=0x00;
TR0=1;
while (TF0==0);
TR0=0;
TF0=0;
}
void main()
{
unsigned int c;
IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2)
EX0 = 1; // Enable EX0 Interrupt
EA = 1; // Enable Global Interrupt Flag
// counter=6709;
P0=num[0];
P1=num[0];
P2=num[0];
while(1)
{
for(c=0;c<154;c++)
{
countdelay(); // 65.535 ms delay
}
counter1=counter%10;
counter2=(counter/10)%10;
counter3=(counter/100)%10;
P0=num[counter1];
P1=num[counter2];
P2=num[counter3];
counter=0;
}
}