| ??? 03/11/03 05:21 Read: times |
#41246 - Serial ISR problems |
Alright, I've read the 8051 data book and searched through the archives and still haven't found anything that identifies the cause of my failed attempt at a rudementary serial routine. My apologies for having to list my code (and my stupidity).
I set up my serial port as follows: clr SM0 ;Mode 1 setb SM1;Mode 1 clr SM2 ;ensure no multi-proc comm setb REN;Rx enable clr TB8 ;Set later for address Tx clr RB8 ;Ensure clear clr TI ;Ensure Tx int is clear clr RI ;Ensure Rx int is clear ;SMOD in PCON mov A,PCON clr ACC.7 mov PCON,A ;set for 9.6 kBaud ;TMOD ;Not required in mode 2 setb ES ;Enable serial interrupt I set up T1 as follows: mov TMOD,#20h ;mode 2 mov TH1,#0fdh ;9.6 kBaud mov TL1,TH1 ;pre-load TL1 BRG setb TR1 ;enable T1 clr ET1 ;the data book says to ;clr the T1 int. Must ;test this The Serial ISR code is as follows: ljmp Ser_ISR reti Ser_ISR: jnb RI,Tx ;If not RI, TI mov @R0,SBUF ;Load RBuff w/ SBUF inc R7 ;Increment Rx count clr RI sjmp Ser_ISR1 ;return to RI/TI Tx: clr TI setb sent Ser_ISR1: ret The failing code is as follows: (line #s added for clarity only) 337 mov SBUF,#'A' 338 nop 339 nop 340 nop 341 jnb sent,$ 342 clr sent 343 mov SBUF,#'B' 344 nop 345 nop 346 nop 347 jnb sent,$ 348 clr sent 349 mov SBUF,#'C' 350 nop 351 nop 352 nop 353 jnb sent,$ 354 clr sent 355 nop 356 nop 357 nop 358 mov SBUF,#'D' 359 jnb sent,$ 360 clr sent 361 nop 362 nop 363 nop 364 mov SBUF,#'E' 365 jnb sent,$ 366 clr sent 367 368 Loop: 369 nop 370 nop 371 nop 372 sjmp Loop I set up HyperTerminal as follows: 8N1 and no flow control My observations: - When I execute this with ET1 cleared and a BP at line 350, hyperterminal shows "AB" and the program hangs - When I execute this with ET1 set and a BP at line 350, hyperterminal shows "ABC" and stops execution as set. - When I set a BP at line 355 (ET1 set), hyperterminal shows "A" and the program hangs. - When I set a BP at line 369, hyperterminal shows "ABC" and hangs. - When I set a BP within the ser ISR after clr RI (within a bunch of nops) hyperteminal shows "ABC" and the program hangs (RI is never set). I can watch the serial data from the PC on my scope connected to the MAX232 output connected to the 8051 Rx. - When I comment out all of the "mov SBUFs" and "jnb sents" and set a BP after clr RI within the ser ISR, the location pointed to by @R0 contains the correct ASCII byte sent to it by hyperterminal. I wrote this to get comfortable with the serial interrupt operation so I only write "ABCDE" to hyperterminal and then wait to accept single bytes from hyperterminal. As I read the data book, TI is set once bit 8 is shifted to the output. So, any suggestions as to why my seemingly straight forward code fails when transmitting? Thanks, in advance. Jeff Biss |
| Topic | Author | Date |
| Serial ISR problems | 01/01/70 00:00 | |
| RE: Serial ISR problems | 01/01/70 00:00 | |
| RE: Serial ISR problems | 01/01/70 00:00 | |
| RE: Serial ISR problems | 01/01/70 00:00 | |
RE: Serial ISR problems | 01/01/70 00:00 |



