hey everyone. i'm trying to eventually build a six digit counter for common cathode seven segment leds. I started off with an example that did two just fine. but everytime I try to add any more to it it refuses to work. I copied an example from a post on this site on how to multiplex them. but still no luck. any ideas?
unsignedshort mask(unsignedshort num);unsignedshort digit_no,digit1000,digit100, digit10, digit1, digit, i;void interrupt(){if(digit_no==0){
PORTA =0;// Turn off all displays
PORTB = digit1;// Set mask for displaying ones on PORTD
PORTA =1;// Turn on display for ones
digit_no =1;}elseif(digit_no==1){
PORTA =0;// Turn off all displays
PORTB = digit10;// Set mask for displaying tens on PORTD
PORTA =2;// Turn on display for tens
digit_no =2;}elseif(digit_no==2){
PORTA =0;
PORTB = digit100;
PORTA =3;
digit_no =3;// Turn on display for hundreds}elseif(digit_no==3){
PORTA =0;
PORTB = digit1000;
PORTA =4;// Turn on display for thousands
digit_no =0;}
TMR0 =0;// Reset counter TMRO
INTCON =0x20;// Bit T0IF=0, T0IE=1}void main(){
OPTION_REG =0x80;// Set timer TMR0
TMR0 =0;
INTCON =0xA0;// Disable interrupt PEIE,INTE,RBIE,T0IE
PORTA =0;// Turn off all displays
TRISA =0;// All port A pins are configured as outputs
PORTB =0;// Turn off all display segments
TRISB =0;// All port D pins are configured as outputsdo{for(i =0; i<=9999; i++){// Count from 0 to 9999
digit = i % 10u;
digit1 = mask(digit);// Prepare mask for displaying ones
digit =(char)(i / 10u)% 10u;
digit10 = mask(digit);
digit =(char)(i / 100u)% 10u;
digit100 = mask(digit);
digit =(char)(i / 1000u)% 10u;
digit1000 = mask(digit);
Delay_ms(1000);}}while(1);// Endless loop}unsignedshort mask(unsignedshort num){switch(num){case0:return0x3F;case1:return0x06;case2:return0x5B;case3:return0x4F;case4:return0x66;case5:return0x6D;case6:return0x7D;case7:return0x07;case8:return0x7F;case9:return0x6F;}}