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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/27/10 22:32
Read: times


 
#176252 - Which ... are you worrying about?
Responding to: ???'s previous message
Do you mean you want to see what the rest of my interrupt handler does? I was trying to avoid bogging the forum down with irrelevant (in my opinion) detail, but here it is...

serint1: 
	clr	ES1    		        ; Disable further serial interrupts on UART2.
        push    ar2
	push    psw
	push    acc
	push    b
	push    DPL
	push    DPH
	clr	RI1
#ifdef SERINT_MONITOR
	mov     DPTR,#stop_drive+serintmon_pin
	mov     a,#1
	movx    @DPTR,a                 ; Output to ON coil every time we get an interrupt.
#endif  // SERINT_MONITOR
#ifdef LOOP_BACK
#ifndef LOOPBACK_ALWAYS
        mov	DPTR,#keyboard+loopback_enable_pin
        movx    a,@DPTR
        anl     a,#loopback_enable_bit
        jz      ser1_1a                 ; If loop-back enable pin is high,
#endif  // LOOPBACK_ALWAYS
        mov     a,SBUF1                 ; read the byte,
	setb	tr1_enab                ; turn on driver,
	mov     r2,#0
	djnz    r2,$                    ; Wait for 1/12us x 4 per cycle x 2 cycles x 256 = 0.17ms
	mov	SBUF1,a                 ; re-transmit the byte,
	jnb	TI1,$                   ; wait for transmit complete bit (no timeout),
	clr	TI1
	mov     r2,#0
	djnz    r2,$                    ; Wait for 1/12us x 4 per cycle x 2 cycles x 256 = 0.17ms
        jmp     ser1_1                  ; and do nothing else.
ser1_1a:
#endif  // LOOP_BACK
	mov	a,SBUF1
        jb      transmit_flag,ser1_1    ; Ignore further characters while transmit flag is set (i.e. until the 
	                                ; data - either remote or main - has been successfuly transmitted to the organ and acknowledged).
	                                ; This is simply because interrupting the send would cause a long delay which would 
	                                ; probably cause the receiving organ to time out. 
	cjne	a,#0FCh,ser1_1
	mov	DPTR,#keyboard2
	jmp	ser1_2
ser1_1:	
	clr	tr1_enab                ; Anything other than start marker, turn off driver.
	pop     DPH
	pop     DPL
	pop     b
	pop     acc
        pop     psw
	pop     ar2
	setb	ES1                     ; Re-enable interrupt.
	reti
ser1_2:                                 ; FCh (start marker).
	jnb	RI1,$                   ; Wait for byte (no timeout).
	clr	RI1
	mov	a,SBUF1
;	cjne	a,#0FAh,byte_update
	cjne	a,#0FAh,ser1_4          ; RSB100527 This change is because the code triggered by FBh seems to be unused, and dangerous.
	jmp	ser1_5
byte_update:
	cjne	a,#0FBh,ser1_4
	jmp     ser1_6
ser1_4:	call	send_error1
	jmp	ser1_1
ser1_6:
	mov	r2,#notes_64            ; FBh
again:
	jnb	RI1,$
	clr	RI1
	mov	a,SBUF1
	movx	@DPTR,a
	inc	DPTR
	djnz	r2,again
ser1_5:                                 ; FAh (byte marker).
	jnb	RI1,$                   ; Wait for byte (no timeout).
	clr	RI1
	mov	a,SBUF1
	cjne	a,#0FDh,ser1_7
	jmp	ser1_8
ser1_7:
	anl	a,#3fh
	mov	DPL,a
	jnb	RI1,$                   ; Wait for byte (no timeout).
	clr	RI1
	mov	a,SBUF1
	movx	@DPTR,a                 ; Save the received byte in the correct location.

	jmp	ser1_5                  ; Keep reading data until we see a checksum marker.
ser1_8:                                 ; FDh (checksum marker).
	jnb	RI1,$
	clr	RI1
	mov	a,SBUF1
	mov	b,a
	jnb	RI1,$
	clr	RI1                     ; Receive end_marker from remote console.
	mov	a,SBUF1
	cjne	a,#0FEh,ser1_9
	jmp     ser1_10
ser1_9:
	call	send_error1
	jmp	ser1_1
ser1_10:
	xcall	check_sum
	cjne	a,b,ser1_9
	call	send_okay1
	setb    transmit2_flag          ; This informs main loop to ignore local data and transmit keyboard2 array.
;	mov	p1,#receive_on          ; Turn off RS485 driver.
	clr     tr_enab                 ; Turn off RS485 driver.
	mov	r5,#00h                 ; Required to exit wait!
	pop     DPH
	pop     DPL
	pop     b
	pop     acc
        pop     psw
	pop     ar2
	setb	ES1                     ; Re-enable interrupts.

	reti

 



List of 38 messages in thread
TopicAuthorDate
Trouble with interrupt driven comms on 80C320 serial port 1            01/01/70 00:00      
   CLR ES1?            01/01/70 00:00      
      Good idea but not the solution            01/01/70 00:00      
         As Erik posted, may be the etc. part            01/01/70 00:00      
   I cant' tell if there is a problem in ...            01/01/70 00:00      
      Which ... are you worrying about?            01/01/70 00:00      
         How about commenting "etc"            01/01/70 00:00      
         please post as is, not all the ...            01/01/70 00:00      
            Again without the conditionals            01/01/70 00:00      
               this is NOT an ISR            01/01/70 00:00      
                  Why will jnb RI,$ screw up?            01/01/70 00:00      
                     stick a state machine in the ISR            01/01/70 00:00      
                        To interrupt or not...            01/01/70 00:00      
                           an example            01/01/70 00:00      
                              Avoid infinite loops like the plague            01/01/70 00:00      
                                 Back to the subject - why won't it interrupt?            01/01/70 00:00      
                                    Serial Port Interrupts            01/01/70 00:00      
                                       Yes, I think I've done this correctly            01/01/70 00:00      
                                          Vector Address...            01/01/70 00:00      
                                             I think I've done this correctly...            01/01/70 00:00      
                                                you had me there            01/01/70 00:00      
                                                   Serial port, not port            01/01/70 00:00      
                                          maybe not            01/01/70 00:00      
                                             ES1 is non-standard            01/01/70 00:00      
                                                probably the most common misumderstanding            01/01/70 00:00      
                                                   Thanks for clarification...            01/01/70 00:00      
                                             It works without interrupts...            01/01/70 00:00      
                                                then ...            01/01/70 00:00      
                                                   Even Better ...            01/01/70 00:00      
                                    maybe it does            01/01/70 00:00      
                                       Two things argue against this...            01/01/70 00:00      
   Dunno, but that's a very useful instruction            01/01/70 00:00      
   Dunno..            01/01/70 00:00      
      I have problem with serial port 1 on ds89c450 (www.maxim-ic            01/01/70 00:00      
         MUCH better description needed            01/01/70 00:00      
            not it is not language            01/01/70 00:00      
               Which register bank are you using?            01/01/70 00:00      
                  yes it works now            01/01/70 00:00      

Back to Subject List