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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/13/09 17:10
Modified:
  01/13/09 17:14

Read: times


 
#161493 - serial interrupt?
Must be that I am getting too old, I just cannot figure out what is the problem here. I have done this many times before, and never any problems.

I am trying to send a test string out the serial port. The only thing that is sent is the last byte (the 0Ah).

I am sure that I don't have to clear the TI bit since the interrupt routine takes care of that.

This code works perfectly in the simulator.
Anyone spot the error?

;serial routines using interrupts
$mod51

org 0
	jmp	START	;
org 23h
	jmp	Ser_Int	;
org 30h
;------------------------------------------------------------
; set up uart in mode 1 (8 bits uart) with
; timer 1 in mode 2 (8 bits auto reload timer)

START:
	mov SP,#6Fh	; set up stack
	mov SCON, #50h	; uart in mode 1 (8 bit), REN=1
	orl TMOD, #20h	; Timer 1 in mode 2
	mov TH1, #0FDh	; 9600 Baud at 11.059MHz
	setb ES		; Enable serial interrupt
	setb EA		; Enable global interrupt
	setb TR1	; Timer 1 run
	
	call Test
	jmp $		; endless
;------------------------------------------------------------
;serial interrupt
Ser_Int:
	push ACC	; save accumulator
	jnb RI,Trans	; test if it is a reception
	clr RI		; clear reception flag for next reception
	mov A,SBUF	; read data from uart
	jmp ExitISR	; return
Trans: 
	CLR TI		; clear transmission flag for next trans
ExitISR:
	pop ACC		; restore accumulator
	reti
;------------------------------------------------------------
Test:
	mov	dptr,#Test_String
	call	OutStr
	ret
;********************************************************************
; Send a null terminated string out serial port
;********************************************************************
OutStr:
	clr a
      movc a,@a+dptr	; get character
      jz exit		; stop if char = null
;     jnb TI,$	        ; wait for last bit to transfer
      mov SBUF,A  	;
;
;***If a delay is inserted here, it works!!
;	call	Delay10mS

      inc dptr		; point to next char
      sjmp OutStr
exit:
	ret

Test_String:
DB	'This is a Test',0dh,0ah,0
;-----------------------------------------------------------------
end

 



List of 23 messages in thread
TopicAuthorDate
serial interrupt?            01/01/70 00:00      
   Your Problem            01/01/70 00:00      
      still not working            01/01/70 00:00      
         you need to flag somehow the end of transmission            01/01/70 00:00      
            reply to Jan            01/01/70 00:00      
   Several            01/01/70 00:00      
      To Hans            01/01/70 00:00      
         And my reply to Charles            01/01/70 00:00      
   no interrupts works            01/01/70 00:00      
   the solution            01/01/70 00:00      
      Isn't that what Hans said?            01/01/70 00:00      
      Perfectly????? Prolly should look again.            01/01/70 00:00      
         Got to look ahead...            01/01/70 00:00      
         Another thing to consider            01/01/70 00:00      
            reply to Andy Neil            01/01/70 00:00      
         reply to Michael Karas            01/01/70 00:00      
      why is this a bad idea            01/01/70 00:00      
         Exactly why not perfect !!!            01/01/70 00:00      
         response to Jan Waclawek            01/01/70 00:00      
            interrupts forever            01/01/70 00:00      
            nope            01/01/70 00:00      
               Re: Erik            01/01/70 00:00      
   if you HAVE to mix ...            01/01/70 00:00      

Back to Subject List