??? 12/27/04 11:04 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#83920 - strange mov-s and xch-s Responding to: ???'s previous message |
I assume your display part is OK, and you already verified, that the interrupt routine correctly displays count1 as the rightmost digit, count2, count3 and then count4 as the leftmost digit (although I would NOT display all 4 digits within the interrupt routine and use delays; rather, display only 1 digit at a time, and advance to the next digit the next time the timer interrupt kicks in).
I think the main problem is at the end of the scan routine: done: setb c mov a,r6 mov unit,a mov count1,a xch a,count1 mov count1,a xch a,count2 mov count2,a mov a,count2 xch a,count3 mov count3,a mov a,count3 xch a,count4 mov count4,a exit: ret First, this should NOT be at the end of the keys scan routine - if the key is pressed, it is called many many times and so the display is almost immediately filled (all 4 positions) with the currently pressed key. You should move the "add one character to the display" (shift 1 digit left) routine to after the debounding, before the release test (just before "back2" label - and you don't need the push acc/pop acc there). And I think this is completely defective - have you tried it in a simulator? I think it should go as follows (many people don't know that '51 is NOT a typical accumulator based architecture and some operations can be done directly on the internal memory positions, move is one of them - any two directly addressed positions can be moved from and to): ; assuming valid key code in accumulator mov count4,count3 mov count3,count2 mov count2,count1 mov count1,a PS. Next time, please enclose the code sample between <pre> and </pre> tags to preserve formatting. |
Topic | Author | Date |
calculator style key pad | 01/01/70 00:00 | |
strange mov-s and xch-s | 01/01/70 00:00 | |
strange mov-s and xch-s![]() | 01/01/70 00:00 | |
calculator style key pad | 01/01/70 00:00 |