PIC18F4620 Interrupts

Discussion in 'Embedded Systems and Microcontrollers' started by internetuser2k11, Apr 14, 2012.

  1. internetuser2k11

    Thread Starter New Member

    Apr 14, 2012
    3
    0
    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.
     
  2. chrisw1990

    Active Member

    Oct 22, 2011
    543
    41
    why mikroBasic or mikroC?? why not mplab and C18?
     
  3. internetuser2k11

    Thread Starter New Member

    Apr 14, 2012
    3
    0
    I have not worked in mplab or C18 but I understand C. You can give me the C code.
     
  4. chrisw1990

    Active Member

    Oct 22, 2011
    543
    41
    i can help you develop it if you want.
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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.
     
  6. chrisw1990

    Active Member

    Oct 22, 2011
    543
    41
    i thought you could configure the whole of port b as ext. int's? (havent looked into it but i though it was same as pic16f84
     
  7. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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:

    Code ( (Unknown Language)):
    1.  
    2. For P18 high priorty interrupts reserved word is interrupt:
    3.     void interrupt(void);
    4.  
    5. For P18 low priorty interrupts reserved word is interrupt_low:
    6.     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.
     
Loading...