PDA

View Full Version : Instant interrupts in Basic?



Bulman
- 6th January 2006, 07:44
Hi.
How do you write your instant interrupts? When the desired code for the interrupt is too complex to write in ASM, I've to write in Basic. But I dont like the software /pseudo/ interrupts.

Dave
- 6th January 2006, 11:53
Bulman, First you need to locate the instant interrupt routines written by Tim Box and then place these lines before any other lines in your code:

INCLUDE "INT_CTRL-18F.inc" ' Interrupt Control routines
DEFINE TMR1_FREQ 100
DEFINE TMR1_HANDLER _TIMR1

Then before your main code segment, insert the interrupt routine's. Here is an example of a simple one using a 100 Hz. interrupt to set some pacing counters.
'************************************************* ********************
'INTERRUPT SERVICE ROUTINE FOR TIMER 1
'************************************************* ********************
TIMR1:
LOOPCNTR = LOOPCNTR + 1 'INCREMENT LOOP COUNTER
TIMSTAMP = TIMSTAMP + 1 'INCREMENT VARIABLE
VOTIME = VOTIME + 1 'INCREMENT VARIABLE
LEDTIMR = LEDTIMR + 1
IF LEDTIMR >= 10 THEN
TOGGLE WATCH_DOG 'KEEP WATCHDOG HAPPY
LEDTIMR = 0
ENDIF
RETURN

After the interrupt routine is complete you mearly "Return" to the program. It's that simple. All if the information is in the "Instant Interrupt Routine" documentation.
I can't remember where I found the "Instant Interrupt Routine" include file but if you do a search of the web I'm sure you will find it. LOL

Dave Purola,
N8NTA