mailus
Full Member level 4
i want to design a counter that counts the no of pulses applied to the input pin.i write a program for this but it does not count the signal at all time due to display program.
how to operate these simultaneous operation at a same time in microcontroller.i show my program please help me....
my program written in microc for pic16f877a microcontroller at 1.000MHz clock for proteus simulation i use delay for 100ms
how to operate these simultaneous operation at a same time in microcontroller.i show my program please help me....
my program written in microc for pic16f877a microcontroller at 1.000MHz clock for proteus simulation i use delay for 100ms
Code:
sbit read at rc4_bit;
unsigned int count;
short int ds1,ds2,ds3,ds4,i;
short int mask(short int get)
{
switch (get)
{
case 0: return 0xc0;
case 1: return 0xf9;
case 2: return 0xa4;
case 3: return 0xb0;
case 4: return 0x99;
case 5: return 0x92;
case 6: return 0x82;
case 7: return 0xf8;
case 8: return 0x80;
case 9: return 0x98;
}
}
void display()
{
ds1= (count%10);
ds1= mask(ds1);
ds2=(count/10)%10;
ds2= mask(ds2);
ds3=(count/100)%10;
ds3= mask(ds3);
ds4=(count/1000);
ds4= mask(ds4);
for(i=0;i<=5;i++)
{
portb=(ds4);
portc.f0=1;
portc.f1=0;
portc.f2=0;
portc.f3=0;
delay_ms(100);
portb=(ds3);
portc.f0=0;
portc.f1=1;
portc.f2=0;
portc.f3=0;
delay_ms(100);
portb=(ds2);
portc.f0=0;
portc.f1=0;
portc.f2=1;
portc.f3=0;
delay_ms(100);
portb=(ds1);
portc.f0=0;
portc.f1=0;
portc.f2=0;
portc.f3=1;
delay_ms(100);
}
}
void main()
{
cmcon=0x07;
adcon1=0x06;
trisd=0x00;
portd=0xff;
trisb=0x00;
trisc=0x10;
portc=0xff;
portb=0xff;
count=0;
do
{
if(button(&portc,4,.1,1))
{
count++;
if(count>9999) count=0;
}while(read=~read);
display();
}while(1);
}