hello, i made a code for a pic 16f628a to count from 0 to 99, the thing is that the left digit turns on, and counts as it should be(every time i == 10 j increases), its displays that, but the units doesnt display on the 7 segment.
ive measured with the multimeter and a scope to see if ra2 turns on, but it doesnt, ive tried with other ports as well but it doesnt go high, so i suppose is a code problem.
here is the code:
int i;
int j;
int var;
int conmutador;
void main() {
TRISB = 0;
TRISA = 0;
PORTA = 0;
PORTB = 0;
var = 0;
i = 0;
j = 0;
conmutador = 0;
while(1){
Delay_ms(300);
i++;
Delay_ms(300);
if(i==10){
i = 0;
j++;
}
if(j==10){
j = 0;
}
if(conmutador == 0){
RA2_bit = 1;
RA1_bit = 0;
var = i;
Delay_ms(10);
conmutador = 1;
}
else{
RA2_bit = 0;
RA1_bit = 1;
var = j;
conmutador = 0;
}
switch(var){
case 0 : PORTB = 0x3F;break;
case 1 : PORTB = 0x06;break;
case 2 : PORTB = 0x5B;break;
case 3 : PORTB = 0x4F;break;
case 4 : PORTB = 0x66;break;
case 5 : PORTB = 0x6D;break;
case 6 : PORTB = 0x7D;break;
case 7 : PORTB = 0x07;break;
case 8 : PORTB = 0x7F;break;
case 9 : PORTB = 0x6F;break;
}
}
}
i stands for units
j stands for dozens
im doing the multiplexing by using 2 bc547's
the transistors are working fine, as well as the resistors, the problem is on the pic not activating the pin for units
thanks for your time