PIC18F4620 Interrupts

Thread Starter

internetuser2k11

Joined Apr 14, 2012
3
My circuit consists of 5 pushbuttons connected to RB0-RB4 of PIC18F4620 and an LED connected to port D0. I need a mikroBasic 7.2 or mikroC program which uses Interrupts to monitor RB0 - RB4 pins. If any of the pins go high then it has to either switch on/off the LED. And also if RB0 and RB1 are both high it has to blink the LED 3 times. Can anyone help me with the code.
 

t06afre

Joined May 11, 2009
5,934
All that information you seek will be in the datasheet. But I can see some problems here. RB0 to to RB2 can be configured as external interrupt pins. And RB7 to RB4 do have interrupt-on-change function. But RB3 do not have any interrupt function at all.
 

ErnieM

Joined Apr 24, 2011
8,377
The non-C problem here is the details of how a compiler handles interrupts. It's a pragmatic issue as every compiler seems to solve the task in it's own way.

I don't use that compiler though I have a sample copy here. If you look into the help file under "interrupt" you will find an explanation. For a PIC18 you have the option of using either of the following:

Rich (BB code):
For P18 high priorty interrupts reserved word is interrupt:
    void interrupt(void); 

For P18 low priorty interrupts reserved word is interrupt_low:
    void interrupt_low(void);
PortB interrupt on change may be set to be either priority. Be careful using the Port, as any port access (reading, writing) will reset the change state and can lead to missing a change.
 
Top