This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR2355: counter variable in ISR in .lib issue

Part Number: MSP430FR2355


I have a counter variable that increments within a timer ISR.  This ISR is in a c file that is build as a static library.  Within this project I have a header file which declares the variable extern:

Header File :

extern volatile uint timer2_ISR_ctnr;

C File:

#ifdef TIMERB0
#pragma vector = TIMER2_B0_VECTOR
__interrupt void T2_B0(void)
{
    timer2_ISR_cntr++;
    LPM3_EXIT;
}
#endif

I am getting the following error when I compile the library:

"../Source/lprs_mspConfig.c", line 160: error #20: identifier "timer2_ISR_cntr" is undefined

I planned on defining the variable in main of another project.  Can I not do this?  It seems as if I am never defining the variable WITHIN the library project and it is baulking at this....

Thanks

  • Hi, Thanks for your post!

    >> I planned on defining the variable in main of another project.  Can I not do this?

    I think you can try this approach.

    On the compile error, I will look in the detailed and update to you later.

  • Is this variable declared anywhere within this library C file? Is the header included?

  • Yes the header file is included with the .lib build.  

    The variable is only declared in the header file as I posted above and the ONLY reference in the C file is what I listed.  I did not declare it within the C file.

    I cut and paste the variable into the header and the library now compiles....Possibly a typo of some sort.

    The issue I now see is in my application program main.c (another project) I define the variable:

        volatile uint timer2_ISR_cntr = 0;
    

    But the compiler flags an error, specific to this variable

    undefined first referenced
    symbol in file
    --------- ----------------
    timer2_ISR_cntr D:/Customers/Firmware/LPRS_lib/Debug/LPRS_lib.lib<lprs_mspConfig.obj>

    Can you tell me what I am missing here?

  • It appears as though you are adding the header to the library but that the file with your ISR does not #include it. Which means that when the compiler looks at your ISR it can find nothing within scope telling it what your variable is.The compiler has no clue about that header file unless you #include it.

  • David...

    Please see last post as I added info....

    The file with my ISR does contain the header..

  • I resolved this.....

    Location, location, location is everything.  Definition MUST be moved outside of main.

    Thanks for all the help.

**Attention** This is a public forum