If you've been frequenting the electronics forum you've probably seen my other thread. Since this is a software issue, I've posted this new question here.
So I'm simply testing things, trying to get them to work. I know my programming technique sucks right now... but it SHOULD work.
Here's my code. What I am trying to do is have my 2 digit seven segment display count up from 0 to 99.
I have all of the segments connected to the D pins, so they are controlled strictly by PORTD.
The two transistors for switching between the first and second digit are connected through B6 and B7. Hence why I switch between 0x80 and 0x40 on PORTB.
What happens is this...
It DOES count from 0 to 99, BUT...
The tens digit is VERY dim, and the ones digit seems to write OVER the tens digit. Kinda like when the one's digit is supposed to be displayed, the tens transistor isn't completely off, and therefore both transistors are on, letting current flow to both digits.
I don't THINK this is a software problem (why am I posting it here again?)... What I THINK is happening is that the transistors can't switch fast enough to keep up with what I'm doing. I mean, I'm not delaying the switching at all, it's running at CLK speed. So, since it's switching on and off so fast, it's almost acting like PWM, therefore providing the required voltage to keep the tens digit transistor on while the one's digit is supposed to be displayed.
I just wanted to make sure my programming was ok.
tens = i/10; //Calculate the tens place
ones = i - (tens*10); //Calculate the ones place
Timer_start(); //Start the timer (set the prescalar to 1024)
while(count<2) //Timer is too quick, making it run through twice
PORTB = 0x80; //Turn the tens digit's transistor on
display(tens); //Display the tens digit
PORTD = 0xFF; //Turn all digit segments off
PORTB = 0x40; //Turn the ones digit's transistor on (and tens transistor off)
display(ones); //Display the ones digit
if (TIFR & 0x01) //If timer has finished...
count++; //Increment count since timer is too fast
TIFR |= 0x01; //Reset timer
count = 0; //Reset count
PORTD = 0xFF; //Turn off all display segment LEDs
PORTB = 0x00; //Turn off both transistors
Timer_stop(); //Stop the timer
**Heads off to figure out how to delay the switching down to 500Hz or so...