This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interrupt vector issues ( cant figure it out!)

Hello, I am having issues implementing the ISR routine on the CORTEX-M3, this exact setup works when I use it with RTX but not as standalone code. When I compile it says cancpp.axf: Error: L6218E: Undefined symbol GPI_ISR (referred from startup.o). But no issues when I build with RTX OS selected.

This is a snip-it of code: GPI_ISR should be the function it branches to.

******************************************************************************
;
; The vector table.
;
;******************************************************************************
        EXPORT  __Vectors
                IMPORT  GPI_ISR ;[WEAK]



__Vectors
        DCD     StackMem + Stack            ; Top of Stack
        DCD     Reset_Handler               ; Reset Handler
        DCD     NmiSR                       ; NMI Handler
        DCD     FaultISR                    ; Hard Fault Handler
        DCD     IntDefaultHandler           ; MPU Fault Handler
        DCD     IntDefaultHandler           ; Bus Fault Handler
        DCD     IntDefaultHandler           ; Usage Fault Handler
        DCD     0                           ; Reserved
        DCD     0                           ; Reserved
        DCD     0                           ; Reserved
        DCD     0                           ; Reserved
        DCD     IntDefaultHandler           ; SVCall handler
        DCD     IntDefaultHandler           ; Debug monitor handler
        DCD     0                           ; Reserved
        DCD     IntDefaultHandler           ; PendSV Handler
        DCD     IntDefaultHandler           ; SysTick Handler
        DCD     GPI_ISR                             ; GPIO Port A

.

in the main.c I have


void   GPI_ISR   (void)
{

}

.

Parents Reply Children
  • It's the same with Keil as with Windows as with OS/2 as with Linux.

    Whenever a C++ program needs to access a C function, it has to know that the C function that gets linked in is "C"

    And to let a C program reach a C++ function, the C++ function must specify that it should use "C" naming and calling conventions.

    The reason for the name mangling in C++ is to allow polymorphic functions, where the same function name can be used multiple times but with different sets of argument types. And to get type-safe linking - the linker will only be able to match the symbol names when caller and implementation expects the same set of data types.

    Since C does not have name mangling, C++ is required to have a standard method to declare when name mangling can not be used. So a good C++ book will cover this, and lots of other useful details.

  • Thanks Westermark.
    Although I have read many C++ books ( I honestly don't recall seeing that in them), I have never had the need to mix C++ and C functions directly, until now. The libraries always had the extern "C" in them, and I never paid attention to it much. But thanks for taking the time to explain.