MerryMadDad
Programmer
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
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