Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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
 



List of 28 messages in thread
TopicAuthorDate
Multi Tasking in 8051            01/01/70 00:00      
   No need            01/01/70 00:00      
   to get a taste of it...            01/01/70 00:00      
      Or Not            01/01/70 00:00      
         I am thinking of implementing the superloop            01/01/70 00:00      
            It is one way            01/01/70 00:00      
      microcontroller vs microprocessor            01/01/70 00:00      
         Broad range of microcontrollers            01/01/70 00:00      
   I need help again!!!            01/01/70 00:00      
   Timer + conditional loop.            01/01/70 00:00      
      How do I implement the Interrupt Driven Serail Comm?            01/01/70 00:00      
         Samples            01/01/70 00:00      
         Own work            01/01/70 00:00      
            I am also looking            01/01/70 00:00      
               So where did you get stuck?            01/01/70 00:00      
               it will not            01/01/70 00:00      
               That *is* the trouble with sample code!            01/01/70 00:00      
               look at code library            01/01/70 00:00      
                  You have to read and understand            01/01/70 00:00      
   Some useful links here            01/01/70 00:00      
      Wha shuld the value of TMOD?            01/01/70 00:00      
         what is in TMOD now?            01/01/70 00:00      
            it does not work            01/01/70 00:00      
               what happens to T1 when            01/01/70 00:00      
                  I don't know what happens to TI            01/01/70 00:00      
                     time for some basic debugging            01/01/70 00:00      
                        tx and gnd shorted            01/01/70 00:00      
                           New question, new thread            01/01/70 00:00      

Back to Subject List