??? 09/20/04 14:35 Read: times |
#77704 - Problem with my code |
Hi, My assignment is to write a program which uses a momentary switch to latch an LED on/off. It seems to be intermittant as it's difficult to describe what it is doing...sometimes it works as expected and other times the led just blinks without latching. The switch is connected to pin0 of port A and the LED is connected to pin0 of port E.Any help would be appreciated.Thank you in advance.
.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/OFF MOV A,#0FFH MOV DPTR,#0F901H ;POINT TO PORT E MOVX @DPTR,A ;TURN OFF LEDS TO PORT E 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 READ CLEAR:DEC 40H ;CLEAR FLAG MOV DPTR,#0F901H ;POINT TO PORT E MOV A,#0FFH ; MOVX @DPTR,A ;TURN OFF LED SJMP READ |