PDA

View Full Version : How to use interrupt on pic basic ?



Shamir
- 17th May 2006, 05:36
Hi all,
I'm new here and on picbasic,

I'm working on a old version of program that written in PICBASIC, and I want to add interrupt to it, but I can't understand how to do it...

On picbasic pro, there is "ON INTERRUPT" command but on picbasic I couldn't find how to do it, can you help me ?

I know how to enable the interupt, and check for it, but how do i tell the chip to goto the interrupt routine when he get one ?

Thanks
Shamir

Melanie
- 17th May 2006, 07:15
Interrupts in PBC can only be done in ASSEMBLER. PICBasic itself does not support or handle interrupts. See section 7.3 of the PBC Manual for your limitations.

Refer to the DATASHEET of your PIC in order to discover how to set and enable them.

Read and thoroughly understand the Microchip Mid-Range Reference Manual for the PIC features you intend to use.

Unless you are skilled in Assembler, do not attempt interrupts in PBC.

Since this is a PBC thread, I have moved it out of the PBP Section.

mramos
- 31st May 2006, 23:05
Shamir:

There is a magazine called Nuts and Volts. It has an article this month on interrupts for PBASIC or PBISIC PRO (Sure it was the latter). Might want to get this months copy or see if parts of it are online.

paul borgmeier
- 1st June 2006, 06:22
In some cases you can use the features of the interrupts without really using the interrupts. You can poll the interrupt bits and see when things happen. (The interrupt bits still get set even if all interrupts are disabled). In fact, this is my preferred way of handling most “interrupt issues,” even in PBP!

For example (with a 16F628), if you wanted to use TMR0 interrupts, you could poll for the interrupt bit instead of actually using the interrupts.

Symbol INTCON = $0B ' 16F628 location of INTCON
Main:
TimeLoop:
peek INTCON, B0
if Bit2 = 0 then TimeLoop ; no TMR0 overflow so keep polling
poke INTCON, 0 ; TMRO overflow so reset flag

rest of program here
but less than overflow time of TMR0

goto Main


(Ihave not used PBC for 7 years but think the above format is correct)

What interrupts are you wanting to use?

Paul Borgmeier
Salt Lake City, Utah
USA