Interrupts in external *.c file does not execute

Let us know if there are categories or topics to add, or what we need to do to improve these forums!
Post Reply
frado
Posts: 2
Joined: Thu Mar 20, 2014 7:15 pm

Interrupts in external *.c file does not execute

Post by frado » Fri Mar 21, 2014 8:07 pm

Hello chipKIT community,

I am here because I have a problem with a Microchip Eth. Starter kit (PIC32MX795F512L with chipKIT bootloader), evething is ok with the bootloader, the problem is in the main application (loaded by the bootloader in MPIDE), I am programming ISRs in external .c files as part as my own libraries (DMA-SPI-EXT-CN-Timers) and when one interrupt happens the program trigger the general exception handler with cause "Interrupt". The main application program is working fine without bootloader aside (the main application program running alone in the entire PIC flash and ram memory).
I have some days looking for threads (also in Microchip forum) related with this problem but nothing helps me.

Thanks in advance.

mikes
Posts: 74
Joined: Mon May 14, 2012 10:37 pm

Re: Interrupts in external *.c file does not execute

Post by mikes » Sat Mar 22, 2014 2:04 pm

Do you have your interrupt wrapped in

Code: Select all

extern "C"
{
  ///your code
}
to prevent name mangling?

PS: Posting the code could help us to help you.

User avatar
majenko
Site Admin
Posts: 2165
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: Interrupts in external *.c file does not execute

Post by majenko » Sat Mar 22, 2014 2:18 pm

MPIDE imposes some extra rules as regards interrupts. Mainly, it has its own internal interrupt table.

Instead of defining your own ISR functions as you would in MPLAB-X doesn't always work. Instead you should use the setIntVector(), setIntEnable(), setIntPriority() etc functions to attach your interrupt routine to the interrupt table.

See WSystem.c in the api and various libraries (like the DSPI library or the Servo library) for more detail and examples.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

frado
Posts: 2
Joined: Thu Mar 20, 2014 7:15 pm

Re: Interrupts in external *.c file does not execute

Post by frado » Sat Mar 22, 2014 8:49 pm

mikes wrote:Do you have your interrupt wrapped in

Code: Select all

extern "C"
{
  ///your code
}
to prevent name mangling?

PS: Posting the code could help us to help you.
Ok thanks Mikes, I change each:

Code: Select all

 __ISR()
declaration to:
extern "C" __ISR
still can't understand why? if all __ISR are in *.c files
MPIDE imposes some extra rules as regards interrupts. Mainly, it has its own internal interrupt table.

Instead of defining your own ISR functions as you would in MPLAB-X doesn't always work. Instead you should use the setIntVector(), setIntEnable(), setIntPriority() etc functions to attach your interrupt routine to the interrupt table.

See WSystem.c in the api and various libraries (like the DSPI library or the Servo library) for more detail and examples.
Thanks majenko but by the moment everything works same as in MPLAB X.

By the way I am having some errors of this kind when declared as local variable one global variable that was declare in an external file inside of the MPIDE sketch like this:

Code: Select all

extern WORD INPUTSREG[150];
/tmp/build50.tmp/core.a(main.cpp.o): In function `utoa':
/home/frado/Arduino/MPIDE.../include/stdlib.h:233: multiple definition of `INPUTSREG'
/tmp/build50.tmp/Fade.cpp.o:/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/stdlib.h:233: first defined here

Thanks in advance...

Post Reply