microcontroller 8052 serial interrupt timer1/2 problems

microcontroller 8052 serial interrupt timer1/2 problems

Hi,
I'm not sure whether this is the right place for my question, but I'd post it anyway. I have a 24 byte tx buffer. When i send the buffer from a uM to pc in a polled manner, timer 2 works fine with the following setting:

mov SCON, #01010000b
mov RCAP2L, #0DCh
mov RCAP2H, #0FFh
mov T2CON, #00110100b

but if i try to use serial interrupt (to receive some chars and do some other calculations) then the send is hanged after the 1st char....
my send codes are (with 30h as the beginning of the tx buffer):

Send:
mov R0, #30h
Main:
clr TI
mov SBUF, @R0
Wait: jnb TI, Wait
inc R0
cjne R0,#48h, Main

However, if the baudrate was set by using timer 1 then the code will work fine....timer 1 setting:

mov TMOD,#20h
mov PCON,#80h
mov TH1,#250
mov TCON,#40h
mov SCON,#50h

what was wrong??
pls help, thanks!!

I use a 11.0592 xtal set to generate a baud of 9600. My code which works with timer1 is (but not when timer2 was used):

.equ TxNow, 01h

.equ StackBase,50h

.ORG 0
ajmp Init

.ORG 23h
ajmp SerInt

;[]------------------------[]
;| Interrupt Routines |
;[]------------------------[]

SerInt:
push PSW
push ACC
push 00h
jbc TI,SerOut
jbc RI,SerRx

SerRx:
mov P0,SBUF

SerOut:
pop 00h
pop ACC
pop PSW
reti

CheckRdy:
mov A,P0
cjne A,#'U',cTxNow
setb TxNow
mov P0,#0h
ret
cTxNow:
clr TxNow
ret

;[]------------------------[]
;| Setup |
;[]------------------------[]

Init:

mov TMOD,#20h
mov PCON,#80h
mov TH1,#250
mov TCON,#40h
mov SCON,#50h
setb ES
setb EA

;[]------------------------[]
;| Main Program |
;[]------------------------[]

mov 30h, #'H'
mov 31h, #'e'
mov 32h, #'l'
mov 33h, #'l'
mov 34h, #'o'
mov 35h, #'!'
mov 36h, #' '
mov 37h, #'T'
mov 38h, #'x'
mov 39h, #'R'
mov 3Ah, #'x'
mov 3Bh, #' '
mov 3Ch, #'s'
mov 3Dh, #'u'
mov 3Eh, #'c'
mov 3Fh, #'c'
mov 40h, #'e'
mov 41h, #'s'
mov 42h, #'s'
mov 43h, #'!'
mov 44h, #' '
mov 45h, #':'
mov 46h, #')'
mov 47h, #' '
Main1:
lcall CheckRdy
jnb TxNow, Main1
jbc TxNow, Send

Send:
mov R0, #30h
Main:
clr TI
mov SBUF, @R0
Wait: jnb TI, Wait
inc R0
cjne R0,#48h, Main
clr TxNow
ajmp Main1

.END

When timer2 was used, it would just hang after sending 'H'.....

publicaciones de 4 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de Intel Software Network Support

This inquiry is beyond the scope of what we are able to address in the Intel Developer Services forums. Also, the Intel 8052 Microcontroller is a mature product not currently supported by Intel Customer Support.

To submit issues on currently available Intel Microcontrollers, please use the form at:
http://developer.intel.com/design/support/faq/microcontrollers/support_d...

To review documentation on currently available Intel Microcontrollers, please visit Intel's Developer Web Site at:
http://developer.intel.com/design/embcontrol/index.htm

To locate documentation or message boards specific to the Intel 8052 Microcontroller, you may want to try using a search engine to look for the keywords "microcontroller forum" or "Intel 8052 microcontroller".

Regards,

Lexi S.

IntelSoftware NetworkSupport

http://www.intel.com/software

Contact us

Message Edited by intel.software.network.support on 12-07-2005 04:12 PM

Hi,
At me is the same problem (I'm work with AT89C55WD - ATMEL).
Baud generator is Timer 1 (10400Hz@16Mhz, constant FCh).
After 1st character transmision aborted.
Whether you have found the decision by this problem?
I'll be grateful if you mail me.
Thanks in advance.

Best regards

Hi!
I read the code you had writed follow
.....

mov TH1,#250
mov TCON,#40h
mov SCON,#50h
at a glance, i see that you had meet somes wrong follow so that you can't send data from uM to PC.

1. you calculate wrong the reload value for timer 1. It must be 252 instead 250
2. To can transmitingdata from uM to PC, the first of all you must set TI bit in SCON register to 1 to ensure that the transfer buffer is empty. So the value you have to set for SCON register must be 52H instead 50H.
3.I think you should set the rightvalue for TH1 and SCON register and then set value for TCON. I mean after you init serial port and set the value reload for timer 1 then set TR1 by set value for TCON.

so the true code you should rewrite follow:
....
mov TH1,#252
mov SCON,#52h
mov TCON,#40h

Inicie sesión para dejar un comentario.