chipKIT® Development Platform

Inspired by Arduino™

Interrupts in external *.c file does not execute

Created Fri, 21 Mar 2014 19:07:04 +0000 by frado


frado

Fri, 21 Mar 2014 19:07:04 +0000

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

Sat, 22 Mar 2014 13:04:11 +0000

Do you have your interrupt wrapped in

extern "C"
{
  ///your code
}

to prevent name mangling?

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


majenko

Sat, 22 Mar 2014 13:18:35 +0000

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.


frado

Sat, 22 Mar 2014 19:49:49 +0000

Do you have your interrupt wrapped in

extern "C"
{
///your code
}

to prevent name mangling? PS: Posting the code could help us to help you.

Ok thanks [color=#008000]Mikes[/color], I change each:

__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 [color=#008000]majenko[/color] 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:

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...