I will try to make this question as short as possible. I'm making a "quiz box" that displays the first two of any 20 players that buzz in. I'm using a pic16f77. The program scans 20 ports (buttons) and displays the first two numbers (1-20) on four single digit 7-segment LED displays via a display driver. Also, a speaker buzzes after the first player has buzzed in. Everything works great except for this one "little" bug.
When I first turn on the power, the displays get set to zero's and the program starts scanning the buttons. If I first push a button in the teens (10-19) the first digit is always wrong. For example, in stead of displaying 12, it displays 32 or 72. Next I push a button (1-9) and it displays correctly. If I reset the program and push the same buttons in the same order, the problem occurs again. However, if I reset the program and first push a button (1-9), then push a button (10-20), it displays correctly and every time thereafter until the power switch is toggled off then on again.
The same thing happens when I turn the power on and first press a button (1-9) then a button (10-19) - it displays incorrectly until I reverse the order. I push one (10-19) then one (1-9) and everything works fine.
So, everytime I want to use it, I have to "intialize" it to get past the bug before it will work right. This problem is very perplexing. The program debugs fine. There is absolutely no reason for the mc to be spitting out these goofy numbers. Does anyone have any idea, hardware or software, what could be causing this problem? I hope this wasn't too confusing. Thanks in advance.
Steve