PDA

View Full Version : USART interrupt not interrupting :-(



barkerben
- 5th January 2005, 13:13
Hi,

I've been testing out the USART on my 16F76 by writing a simple echo server. I started off with:


DEFINE OSC 4
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 2400
DEFINE HSER_ CLROERR 1

serial var byte

main:
HSerin [serial]
Hserout [serial]
GoTo main


This worked absolutely fine. I then tried to add interrupts to the program:

DEFINE OSC 4
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 2400
DEFINE HSER_ CLROERR 1


init:
PIE1.5=1 'Enable USART RX interrupts
INTCON.6=1
INTCON.7=1


on interrupt goto handler
main:
'Main loop, does absolutely nothing for the moment
GoTo main

DIsable
handler:
HSerin [serial]
Hserout [serial]

resume
enable

This ought to behave in exactly the same way, except that it doesn't work at all. Have I forgotten to set a needed register to enable interrupts or something ...?


Ben

barkerben
- 5th January 2005, 13:30
Arg! Both the code samnpoles above work perfectly! My problem was with solderus badus on my part! It was pure chance that it worked whenever I loaded one code in, but not the other. My Iron is warming as I speak(write) .... :-)