• AVR Freaks

Hot!How do I catch interrupts on general purpose I/O pins of PIC32?

Author
mnikpour59
New Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2012/04/26 09:41:58
  • Location: 0
  • Status: offline
2012/04/26 10:48:07 (permalink)
0

How do I catch interrupts on general purpose I/O pins of PIC32?

Hey everybody,
I need some sample C code (or help) for catching interrupts raised on GPIO pins of PIC32
Thanks

post edited by mnikpour59 - 2012/04/26 11:03:03
#1

9 Replies Related Threads

    cgiordan
    Super Member
    • Total Posts : 1364
    • Reward points : 0
    • Status: offline
    Re:How do I catch interrupts on general purpose I/O pins of PIC32? 2012/04/26 11:13:51 (permalink)
    0
    You can generate interrupts on CNx pins, INTx pins and ICx pins.  The reference manuals go into the specifics about these peripherals.  There are some examples I believe included in the C32 installation directory to get you started.  The Microchip Application Library (MAL) - Google it - also might include something of the sort, but in general, your best bet is looking in the C32 installation directory.  So, you cannot in general pick some arbitrary pin without understanding what HW is behind it to generate an interrupt. 
     
    My directory structure for the example using the CNx (Change Notice) is as follows:
     
    C:\Program Files\Microchip\mplabc32\v2.02\examples\plib_examples\ports\ports_basic\source
     
    Another example for ICx (Input Capture):
     
    C:\Program Files\Microchip\mplabc32\v2.02\examples\plib_examples\incap\icap_capture_event\source
     
    You get the idea.  Don't be scared to explore the directories of the compiler's install location.  You're going to need to be familiar with a lot of things the more you get into programming with PIC's. 
     
    Also, take a look at the pin-out of your particular device to see which pins are associated with which peripherals.  This will help you make some important decisions. 
    #2
    mnikpour59
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2012/04/26 09:41:58
    • Location: 0
    • Status: offline
    Re:How do I catch interrupts on general purpose I/O pins of PIC32? 2012/04/26 11:23:43 (permalink)
    0
    Thanks for your extensive reply. Let me open it a little bit more. I have designed this board that includes a PIC32 and a Nordic wireless interface. In the manual, I could find a source code example for timer interrupts which was helpful indeed and I'm using that code. So the problem is simple to describe: The Nordic interface raises an interrupt when it receives a packet. The IRQ from Nordic is connected to pin #1 of PIC 32 which is RE5. So can I have an ISR that gets run whenever the RE5 is set high?
    Thanks again
    #3
    cgiordan
    Super Member
    • Total Posts : 1364
    • Reward points : 0
    • Status: offline
    Re:How do I catch interrupts on general purpose I/O pins of PIC32? 2012/04/26 11:38:15 (permalink)
    0
    Which exact PIC32 are you using and which package would be helpful to determine what you can use to interrupt from.  Based on what you are telling me and the available PIC32 packages where pin 1 is RE5, the data sheet and pin-out information contained within it looks as if you are out of luck with any of these being able to generate an event because RE5 is not a CNx, ICx, or INTx pin.  Your only option is to poll this pin once configured as an input unfortunately.  Another option is to re-route this Nordic interface line to a different pin if possible.  Inspect the pin-out of your device in the device specific datasheet to find out what pin you can generate an interrupt off of. 
    #4
    SJFreeland
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2017/05/05 21:47:46
    • Location: 0
    • Status: offline
    Re:How do I catch interrupts on general purpose I/O pins of PIC32? 2019/09/03 15:05:29 (permalink)
    0
    The last post to this thread is April, 2012. Are there any changes to this information for September, 2019?
    #5
    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re:How do I catch interrupts on general purpose I/O pins of PIC32? 2019/09/03 20:17:15 (permalink)
    0
    It still depends upon the same question.
    cgiordan
    Which exact PIC32 are you using and which package
    ...

    In my opinion, if you don't mind a couple of millisecond delay from the pin being asserted, polling it in a timer interrupt is a perfectly satisfactory way to handle the OP's situation.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    marcov
    Super Member
    • Total Posts : 253
    • Reward points : 0
    • Joined: 2006/10/08 01:59:40
    • Location: Eindhoven, NL.
    • Status: offline
    Re:How do I catch interrupts on general purpose I/O pins of PIC32? 2019/09/04 04:54:04 (permalink)
    0
    Note that the mentioned application libraries are not updated for anything but 32MX.  So afaik no mk or mz.
    #7
    Sal Ammoniac
    Super Member
    • Total Posts : 219
    • Reward points : 0
    • Joined: 2011/11/27 14:04:14
    • Location: 0
    • Status: offline
    Re:How do I catch interrupts on general purpose I/O pins of PIC32? 2019/09/04 09:23:33 (permalink)
    5 (1)
    marcov
    Note that the mentioned application libraries are not updated for anything but 32MX.  So afaik no mk or mz.

    The functionality of CN and IC on PIC32 is so simple, why bother with libraries? Just implement the needed functionality at the register level.
    #8
    marcov
    Super Member
    • Total Posts : 253
    • Reward points : 0
    • Joined: 2006/10/08 01:59:40
    • Location: Eindhoven, NL.
    • Status: offline
    Re:How do I catch interrupts on general purpose I/O pins of PIC32? 2019/09/15 13:52:00 (permalink)
    0
    I don't know about the CN and IC details by heart, but in general code using peripheral libraries is usually easier to port part to part.
    #9
    NKurzman
    A Guy on the Net
    • Total Posts : 17847
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re:How do I catch interrupts on general purpose I/O pins of PIC32? 2019/09/15 14:08:55 (permalink)
    0
    That assumes porting Part to part it desired or required. General code has the downside of being general. It may not be optimized for any part. It is up to the project architect to decide.
    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5