??? 02/04/09 10:05 Read: times |
#162034 - I need help again!!! Responding to: ???'s previous message |
How do I interrupt 8051 when it is busy. For example, it is program to be delayed for 5 minutes, but I want to cancel the delay from searial communication. I have the ff code, and I could not seem to make it work:
ORG 00H ; Reset ljmp start org 03 ljmp isr0 org 80h start: setb it0 setb ex0 MOV TMOD,#20H ;enable timer1, mode 2 (auto reload) MOV TH1,#0FDH ;9600 Baud rate MOV SCON,#50H ;8 bit, 1 stop bit, REN enabled SETB TR1 HERE:JNB RI,HERE ;wait for character to come in MOV A,SBUF ;get data in A CJNE A,#0FFH,DOWN ;chk if the char is synch byte ie.offh or 255 ;if not jump to clear RI CLR RI ;get ready to get next byte WAIT:JNB RI,WAIT ;wait for character to come in MOV A,SBUF ;get data in A CJNE A,#00H,NXT ;chk if the char is 0 CLR P1.4 ;switch on LED SJMP DOWN ;jump to clear RI nxt:CJNE A,#02H,NXT1 ;chk if the char is 2 mov r6, #00h clr p3.2 push 00 push 01 mov r0,#30 bbbb: mov r1,#255 cccc: djnz r1,cccc djnz r0,bbbb pop 01 pop 00 setb p3.2 SJMP DOWN ;jump to clear RI NXT1:CJNE A,#01H,bxt1 ;chk if the char is 1 SETB P1.4 ;switch off LED SJMP DOWN ;jump to clear RI bXT1:CJNE A,#031H,nxt4 ;chk if the char is 1 mov r6, #01h SJMP DOWN ;jump to clear RI nxt4: cjne a,#04H, down start1: mov dptr, #dots mov r0, #18h loopq: clr a MOVC A,@A+DPTR CLR TI MOV SBUF,A JNB TI,$ INC dptr delay_16ms: push 00 push 01 mov r0,#30 delay_16ms_loop1: mov r1,#255 delay_16ms_loop2: djnz r1,delay_16ms_loop2 djnz r0,delay_16ms_loop1 pop 01 pop 00 djnz r0, loopq ; DOWN:CLR RI ;get ready to get next byte SJMP HERE ;keep getting the data delay: dec a d_olp: push acc mov a, #0a6h d_ilp: inc a nop nop nop nop jnz d_ilp nop nop pop acc djnz acc, d_olp mov a, #0a6h d_lp2: inc a nop nop nop nop jnz d_lp2 nop nop nop ret isr0: mov r5, #0ffh loop5: mov r1, #0ffh loop1: lcall delay cjne r6, #00, nxt3 djnz r1, loop1 djnz r5, loop5 CLR P1.4 ;switch on LED nxt3: reti dots: db "Eibox is now connected!" end |