??? 09/21/04 12:20 Read: times |
#77799 - RE: Replacing school hardware Responding to: ???'s previous message |
Hi Craig, I think the error you speak of is the missing debounce but the assignment had two parts, write one program with debounce and one without. Either way my code doesn't seem to work. Raghu has given me another idea which I will work on next. In the meantime here is my code with the debounce: To clear up some confusion the first three lines work together to set up port A as an input, similiarly the next three set up port E as an output. The professor recommended a 250ms delay for debounce, perhaps this is overkill but can it hurt?
.ORG 2000H MOV A,#9FH ;SET UP MOV DPTR,#0F803H ; PORT A MOVX @DPTR,A ; AS AN INPUT MOV A,#89H ;SET UP MOV DPTR,#0F903H ; PORT E MOVX @DPTR,A ; AS AN OUTPUT MOV 40H,#00 ;CLEAR FLAG-IS LED ON OR OFF MOV A,#0FFH MOV DPTR,#0F901H ;POINT TO PORT E MOVX @DPTR,A ;TURN OFF ALL LED ATTACHED TO PORT E DELAY:ACALL DLY250 ;CALL DELAY (SWITCH BOUNCE) READ:MOV DPTR,#0F800H ;POINT TO PORT A MOVX A,@DPTR JNZ DELAY MOV A,40H ;MONITOR FLAG JNZ CLEAR ; INC 40H ;SET FLAG MOV DPTR,#0F901H ;POINT TO PORT E MOV A,#0FEH ; MOVX @DPTR,A ;TURN ON LED SJMP DELAY CLEAR:DEC 40H ;CLEAR FLAG MOV DPTR,#0F901H ;POINT TO PORT E MOV A,#0FFH ; MOVX @DPTR,A ;TURN OFF LED SJMP DELAY DLY250:MOV R3,#3 LOOP:MOV R4,#150 LOOP1:MOV R5,#255 LOOP2:NOP DJNZ R5,LOOP2 DJNZ R4,LOOP1 DJNZ R3,LOOP RET |