??? 05/27/10 20:31 Read: times |
#176243 - Trouble with interrupt driven comms on 80C320 serial port 1 |
I'm having trouble with a serial application using the Dallas 80C320. I'm using serial port 1 in mode 1 (8-bit UART) using timer 1 to generate the baud rate. I have an 11.0592 MHz crystal, and am operating at 57,600 baud. The port works fine when I use it without interrupts. I can send and receive characters at 57,600 baud, and everything seems perfect. But when I enable interrupts, nothing happens. I've put an output to a LED in my interrupt handler, and it never gets fired, so I'm pretty sure the interrupt handler is never being reached. What am I doing wrong?
Here's my initialisation code: start: mov SP,#?stack-1 mov IE,#0 ; Disable all interrupts. mov P1,#0 ; Turn off tr_enab and tr1_enab. ; This is for serial port 0 mov t2con,#030h ; Use Timer 2 in auto reload mode for both receive and transmit baud clocks. mov RCAP2L,#T2RL96L mov RCAP2H,#T2RL96H mov TL2,#T2RL96L mov TH2,#T2RL96H mov SCON,#050h ; Serial port 0 mode 1 (8-bit UART), Receive Enable. mov a,#2 ; Stretch value. External RAM access via MOVX uses 4 machine cycles. mov CKCON,a ; T1M (CKCON.4) is 0 so timer 1 runs at crystal/12. setb TR2 ; Turn on timer 2. ; This is for serial port 1 mov tmod,#020h ; Timer 1 mode 2: 8-bit auto-reload mode. mov th1,#255d mov tl1,#255d mov scon1,#050h ; Serial port 1 settings: mode 1 (async 10-bit), receive enable. setb smod ; Set smod_1 to double the baud rate. clr RI1 ; If it`s edge triggered, we may never get an interrupt if TI or clr TI1 ; RI are already set when interrupts are enabled. setb ES1 ; Enable interrupts. setb EA ; Global interrupt enable. setb tr1 ; Turn on timer 1. Port is now live. I've included all of it including the stuff for port 0 just in case there's some interaction I've not spotted. This exact code, without the setb ES1 and setb EA, works fine for non-interrrupt IO. When I add the two setb's though I don't seem to get any interrupts. I have the following interrupt vector: ORG 003bh ljmp serint1 In serint1 I have: serint1: clr ES1 push ar2 push psw push acc push b push DPL push DPH clr RI1 etc. Then I have my output to a LED which never happens. What am I doing wrong? Many thanks - Rowan |