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 12:33
Read: times


 
#4201 - RE: Serial Init
It's rather easy, if you read the informaton at:

http://www.8052.com/tut8051.htm

You must make deeper in handling SFR-registers in 8051,
and the description on that adress is made for us newbies.!

You must handle SCON, TCON and TMOD.

When you get it - it works very well, and smart.!

Preferably use an 11.0592 MHz Xtall to get right divider.
It's an standard-frequencies in many xtals-types to
use in just this case.
And you can in that case get the setup instruction here
for 9600 baud serial:

;SFR Registers and Serial com presettings

MOV TCON,#0C0h ;Sets Timer control register
MOV TMOD,#21h ;T1 Sets to 8-bit Auto-Reload
MOV SCON,#5Fh ;Sets the serial com. mode
;MOV PCON,#00h ;Power-reg to "0"***not used.!
MOV TH1,#0FDh ;Divider for baudrate. 9600 baud
SETB EA ;Global Interrupt settings. (on)
CLR ET0 ;Timer (T0) set. (off)

Now - Automaticly the uP implement start and stop-bit
so you don't have to think aboute it. It's icluded in that
setup, and hanles by the uP
Obvious you use the ordinary TxD and RxD - port.

Then you use the SBUF-register to handle the serial-info.

Anyway- i'l recomend that you read the info from the adress
i gave you, it's from this site I've learn - and for me - it works.

Here is an easy one:

CLR TI ;Be sure the bit is initially clear
JNB RI,$ ;Wait for the 8051 to set the RI flag
MOV A,SBUF ;Read the character from the serial port
MOV SBUF,A
JNB TI,$

When you now sen a character from e.g hyperterminal.
you get an echo back again - but don't forget to
connect pin 7 and 8 in serial-port together.

THATS ALL FOLKS
Magnus Munthe /// Sweden





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