7 segment multiplexing problem in pic using microc

Status
Not open for further replies.

mailus

Full Member level 4
Joined
Mar 6, 2012
Messages
234
Helped
7
Reputation
16
Reaction score
7
Trophy points
1,308
Location
-
Activity points
2,706
I programmed a counter that counts pulses at RB0 pin.It displays the no of counts in 7 segment display the display is multiplexed.
in real time initially the display shows 1234 as programmed(approximately).some time the display shows correctly.but some time it does not display correctly.
pictures added.







my code is here
Code:
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 interrupt()
{

if(rb0_bit)
{

intcon.intf=0;
delay_ms(10);
count++;
if(count>9999) count=0;
}
}

void main()
{
cmcon=0x07;
adcon1=0x06;
option_reg.intedg=1;
INTCON.GIE = 1;
INTCON.INTE = 1;
 trisd=0x00;
 trisb=0x01;
 trisc=0x10;
 portc=0xff;
 portd=0xff;
 count=1234;
 do
 {
  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<50;i++)
  {
   portd=(ds4);
   portc.f0=0;
   portc.f1=1;
   portc.f2=1;
   portc.f3=1;
   delay_ms(1);
   portd=(ds3);
   portc.f0=1;
   portc.f1=0;
   portc.f2=1;
   portc.f3=1;
   delay_ms(1);
   portd=(ds2);
   portc.f0=1;
   portc.f1=1;
   portc.f2=0;
   portc.f3=1;
   delay_ms(1);
   portd=(ds1);
   portc.f0=1;
   portc.f1=1;
   portc.f2=1;
   portc.f3=0;
   delay_ms(1);
  }
 }while(1);
}



pls help...

- - - Updated - - -

i can't add the image.so i attached the problem as picture
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…