[SOLVED] Using main.cpp (C++) disables INT handling for peripherals (NRF52, SAMD21)

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Using main.cpp (C++) disables INT handling for peripherals (NRF52, SAMD21)

    Hi,

    Seems like a bug of sorts, but using both the above mentioned chips with fresh projects I found numerous event handlers were not 'linked' when main was a c++ file, while c works. It could be all of them in fact but certainly TIMERS on the NRF52 and EXT INTS on the SAMD21. This caused the CPU's to appear hard locked.

    It took me absolutely ages to work out what was causing it, although not the underlying issue.

    Keep up the great work, Segger is my go-to environment going forward.

    Regards,

    Andrew
  • Hello Andrew,

    This is not a bug, if you use C++ compiler, you should mark your ISR functions with extern "C" to instruct the compiler to use C linkage.
    That way, your ISR functions will be linked with the proper symbols in the vector table.

    Hope it helps.

    BR,
    Thomasso