Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

89S8252 UART not working !

Status
Not open for further replies.

MerryMadDad

Programmer
Dec 11, 2001
47
GB
Hello all,
I'm trying to get the serial port of an Atmel 89S8252 to transmit data in mode 2 of the Serial port (Mode 2 should be 8 bit UART fixed baud rate)

Here's some of the code :

;-------------- Timer 0 Setup

Mov A,TMOD
Anl A,#0F0H
Orl A,#02H ;8 bit auto re-load timer 0
Mov TMOD,A

Setb Et0 ;Enable timer interrupt
Setb Tr0 ;Start timer

;-------------- Serial Port Setup

Orl pcon,#00 ;Set baud rate at 1/64 osc.

(Crystal is 4.9152 so baud should be 9600)

Setb Sm0 ;Set port to mode 2
Setb Ren ;Enable receive
Clr sm1 ;make sure of mode
Setb ea ;Enable all Interupts

Not using the serial port interupt at the moment ES not enabled, so here's the code that's supposed to send data out of the serial port :


Loop: .
.
.
Mov A,#254
Anl Sdata1,A
Lcall SrlSend
Mov A,#253
Anl Sdata2,A
Lcall SrlSend
.
.
.
some other stuff
ljmp loop



SrlSend: Clr ti
Mov sbuf,Sdata1 ;Send first byte
Jnb ti,$
Clr ti
Mov sbuf,Sdata2 ;Send second byte
Jnb ti,$
Clr ti
Ret


Only problem is it doesn't work !

Have I done something daft, or do I have to set up p3 in some way before I can use the UART ?

I am checking for output on pin 11 of 89S8252 using a frequency counter set to totalize, that way, I hoped that I would see if the output on the pin toggled at all but it does not change (remains high).

The rest of the program works correctly, does not get stuck at JNB ti,$ as you might expect if the serial port was not working at all, also p3.1 is not accesed anywhere else in the program (not held in some fixed state that I can determine).


Any ideas ?

Any help would be much appreciated

Thanks and Regards.


MMD
 
All the code I have uses Timer 1 to generate the baud rate.

Can't remember at the moment if there's a good reason for this, but a quick look at the data sheet doesn't seem to mention using Timer 0.

rgds
Zeit.
 
Hi Zeit,

In mode 2 of the UART none of the timers are used to generate the baud rate, it comes from the oscillator which in my case is 4.9152mHz / 64 should be 9600. I took your advice from your earlier reply to another posting of mine and got some info that way, but still can't get this thing to work ! I'll try it again, this time using one of the timers to generate the baud rate.

Thanks

Robert
 
Yes, I see what you mean.

I've never used that mode, so I can't really comment.

From the databook, it should start transmitting when you write to SBUF. (Ha! we've all heard that one before!).

If you use timer 1, the divide ratios will require a 11.05MHz resonator or xtal to give reasonable baud rates.

Hope this is helping a little.

rgds
Zeit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top