??? 08/27/06 14:16 Read: times |
#123136 - problem with delays |
This is an extract of a key scan subroutine where port 0 is interfaced to a 4x3 keypad.
;--------------------------------------------------------------------------------- WAIT1:MOV R0,#03H ;values of r0,r1 & r2 together provide a delay of 423ms WAIT2:MOV R1,#0FFH WAIT3:MOV R2,#0FFH CONFIRM_KEY_PRESS: MOV A,P0 ;p0.0 t0 p0.3 => rows, p0.4 to 0.6 => columns ANL A,#01110000b ;scan columns cjne a,#01110000b,KEY_PRESS_CONFIRMED; if key pressed within 423ms, come out of delay loop DJNZ R2,CONFIRM_KEY_PRESS DJNZ R1,WAIT3 DJNZ R0,WAIT2 SJMP SECOND_KEY_SCAN1 ;if no key is pressed within 423ms, come out of key checking subroutine;---------------------------------------------------------------------------------- The code is supposed to come out of the delay loop(CONFIRM_KEY_PRESS) and jump to 'loop1' if a button is pressed within the specified time of 423ms. If no button is pressed within the specified 423ms delay, the code is supposed to jump to 'loop2'(SJMP SECOND_KEY_SCAN1). But the problem is that the code never jumps to 'loop2'(SJMP SECOND_KEY_SCAN1), even if no key is pressed within 423ms. The code jumps to 'loop1'(KEY_PRESS_CONFIRMED) on pressing a button. Ashwin.V |
Topic | Author | Date |
problem with delays | 01/01/70 00:00 | |
Omitted pull-ups at Port 0? | 01/01/70 00:00 | |
No, it's pulled high | 01/01/70 00:00 | |
You should see the connection... | 01/01/70 00:00 | |
could it be your approach? | 01/01/70 00:00 | |
p0 initialised as input port | 01/01/70 00:00 | |
post the WHOLE code | 01/01/70 00:00 | |
WHOLE code | 01/01/70 00:00 | |
Try this | 01/01/70 00:00 | |
WHOLE code | 01/01/70 00:00 | |
Assuming that the external pullups are not working | 01/01/70 00:00 | |
why is the delay not being excecuted? | 01/01/70 00:00 | |
HOW DO YOU KNOW | 01/01/70 00:00 | |
Through debugging | 01/01/70 00:00 | |
I know nothing about keil debugger | 01/01/70 00:00 | |
make code that resembles the flowchart and you wil | 01/01/70 00:00 | |
whole? | 01/01/70 00:00 | |
Ashwins stack handling is totally unsuited! | 01/01/70 00:00 | |
to generate tone of octave(8keys)with 89c51 | 01/01/70 00:00 | |
sandy please start a new thread![]() | 01/01/70 00:00 |