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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/07/00 13:00
Read: times


 
#4202 - RE: Serial Init
Ben,
This does sound like a simple question, so if you don't mind, I'm using this opportunity to wet my feet here and attempt to provide an answer. I'm sure that there are others out there who can provide a better or clearer answer, but here goes:

Timer1, use Mode 2; Serial Interface, use Mode 1.
; clear Serial Interrupt Enable
; and Timer1 Overflow Interrupt Enable
CLR IE.4
CLR IE.3
; set up Timer1
; clear Timer1 Run bit to disable timer
CLR TCON.6
; note: TMOD not bit-addressable
MOV A,TMOD ;get current TMOD value
ANL A,00FH ;preserve Timer0 setup
; set Timer1 to Mode 2, no gating
ORL A,020H
MOV TMOD,A ;set up Timer1
; set up Timer1 timing for serial clock
; note: this value assumes a 11.06MHz system clock
MOV TH1,0FDH ;set Timer1 reload value

; set up Serial Interface
; do not enable Rx just yet.
MOV SCON,040H ;set Mode 1
; clear SMOD bit in PCON register
; note: PCON not bit-addressable
MOV A,PCON ;get current PCON value
ANL A, 07FH ;clr SMOD, preserve other bits
MOV PCON, A
; now start everything up
SETB TCON.4 ;start Timer1
SETB SCON.4 ;enable Rx

; now poll RI bit in SCON for receipt of characters

JBC SCON.0, GOT_CHAR

LJMP DO_OTHER_STUFF

GOT_CHAR:
MOV A, SBUF ; get character received
.
.
.

Hope this helps.
Anyone else out there, don't flame me too harshly; I think I dotted all of my i's and crossed my t's.

Chris Jones

List of 5 messages in thread
TopicAuthorDate
Serial Init            01/01/70 00:00      
RE: Serial Init            01/01/70 00:00      
RE: Serial Init            01/01/70 00:00      
RE: Serial Init            01/01/70 00:00      
RE: Serial Init            01/01/70 00:00      

Back to Subject List