What has happened to _cortex_int_init in MQX4

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What has happened to _cortex_int_init in MQX4

1,570 Views
OliverSedlacek
Contributor III

I am developing on a Kinetis K60 and on MQX3.8 I was successfully using _cortex_int_init() to call my ISR handler on a port edge interrupt. Now that I have to use MQX4, it doesn't compile as there's no definition in <cortex.h>. I tried _bsp_int_init() but that gets translated to _nvic_int_init(), which the compiler can find in <nvic.h> but the linker can't! All I can find in <cortex.h> is _psp_int_init(), but I've no idea if that's equivalent or what the arguements are?

Can anyone help?

Tags (2)
0 Kudos
14 Replies

844 Views
guillaumetiffin
Contributor III

I have exactly the same problem as Oliver but I use the _cortex_int_init() to call the isr handler on a FTM interrupt.

In my psp.a I have no occurence of "nvic_int_init" but the function _nvic_int_init() works.

I you want I can share my code but it's only demo code.

0 Kudos

844 Views
c0170
Senior Contributor III

Hello Guillaume Tiffineau,

where is nvic_int_init linked from ? You alleged it works but you have same problem, which confused me. What are you having difficulties with?

If you can share your demo code, it could be useful.

Regards,

c0170

0 Kudos

844 Views
guillaumetiffin
Contributor III

Hello,

Sorry for my english. I think that some misunderstanding can come from this.

I said that I have the same problem because when I transfered my project to use the mqx4.0, I had a lot of error with the function _cortex_int_init(). But I tried to replace it with the _nvic_int_init() function and it worked perfectly.

I fact I did'nt found the nvic_int_init in the psp.a file because I done a mistake. But now I found it.

for the code.

In my include I have

#include <mqx.h>

#include <bsp.h>

#include <lwevent.h>

#include <FTM_PDD.h>

And Here is the code that I use

void Quad_Config(_QUAD QuadNumber, int_16 Resolution, boolean EnableInterrupt)

{

    FTM_MemMapPtr PeripheralBase;

  

    PeripheralBase = Quad_GetPeripheral(QuadNumber);      

  

    if(PeripheralBase != NULL)

    {

        if(QuadNumber == QUAD_1)

        {          

              SIM_SCGC6 |= SIM_SCGC6_FTM1_MASK;

        }

        else if (QuadNumber == QUAD_2)

        {          

              SIM_SCGC3 |= SIM_SCGC3_FTM2_MASK;

        }

      

        if(EnableInterrupt == TRUE)

        {

            FTM_PDD_EnableOverflowInterrupt(PeripheralBase);

        }

      

        FTM_PDD_WriteFeaturesModeReg(PeripheralBase, 1);

      

        FTM_PDD_WriteConfigurationReg(PeripheralBase, 96);

      

        FTM_PDD_WriteModuloReg(PeripheralBase, Resolution);

      

        FTM_PDD_InitializeCounter(PeripheralBase);

                

        FTM_PDD_WriteQuadratureDecoderReg(PeripheralBase, 1);

          

          

        if(QuadNumber == QUAD_1)

        {                        

            FTM1_SC |= FTM_SC_CLKS(1);

          

            PORTA_PCR(8) = PORT_PCR_MUX(6);

          

            PORTA_PCR(9) = PORT_PCR_MUX(6);

          

            if(EnableInterrupt == TRUE)

            {

                FTM_PDD_EnableOverflowInterrupt(PeripheralBase);

              

                _int_install_isr(INT_FTM1, (void(_CODE_PTR_)(pointer))Quad_irq_callback, (void *)1);

              

                _nvic_int_init(INT_FTM1, 4, TRUE);

                    

//                _cortex_int_init(INT_FTM1, 4, TRUE);

          

            }  

        }

        else if (QuadNumber == QUAD_2)

        {                              

            FTM2_SC |= FTM_SC_CLKS(1);

          

            PORTB_PCR(18) = PORT_PCR_MUX(6);

            

            PORTB_PCR(19) = PORT_PCR_MUX(6);

          

            if(EnableInterrupt == TRUE)

            {

                FTM_PDD_EnableOverflowInterrupt(PeripheralBase);

              

                _int_install_isr(INT_FTM2, (void(_CODE_PTR_)(pointer))Quad_irq_callback, (void *)2);

              

//                _cortex_int_init(INT_FTM2, 4, TRUE);

              

                _nvic_int_init(INT_FTM2, 4, TRUE);

            }

        }

    }  

      

}


I put the complete project in attachement.

I don't know if it will help you.

Regards.


0 Kudos

844 Views
Martin_
NXP Employee
NXP Employee

your TestRtos project doesn't build, because it has wrong paths to MQX libraries. In MQX 4.0, the paths to libraries have changed. For example from:

"${MQX_ROOT_DIR}/lib/twrk60f120m.cw10/bsp"

to

"${MQX_ROOT_DIR}/lib/twrk60f120m.cw10/debug/bsp"

and

"psp_twrk60f120m_d.a"

changed to

"psp.a"

so if I change all the paths to include "debug" in it (including path to the .lcf file), your project builds without any problem.

By the way, _cortex_int_init() from previous MQX releases should be replaced by _bsp_int_init()

change from:

_cortex_int_init(INT_TSI0, 4, TRUE);

change to:

_bsp_int_init(INT_TSI0, 4, 0, TRUE);

on ARM Cortex M4 targets that would translate to _nvic_init_init().

0 Kudos

845 Views
Martin_
NXP Employee
NXP Employee

1)

check that nvic_int_init is in your psp.a. for example my psp.a is in this folder:

c:\Freescale\Freescale_MQX_4_0\lib\twrk60d100m.cw10\debug\psp\psp.a

and if you open in text mode and search for the string "nvic_int_init" it has multiple references.

if the psp.a has the nvic_int_init function object code, move on to 2)

2)

check the settings of the linker in your application.

It should be configured to look for additional object code from

${MQX_ROOT_DIR}\lib\twrk60d100m.cw10\debug\psp

psp.a

is the name of the library.

MQX_ROOT_DIR = c:\Freescale\Freescale_MQX_4_0   (your MQX 4.0 installation folder)

0 Kudos

845 Views
OliverSedlacek
Contributor III

There are 8 occurences of the string nvic_int_init in my psp.a

I'm using IAR so I added the c:\freescale.......\debug\psp\psp.a file to the 'Additional libraries: (one per line)' text box of the linker tab but I still get:

Error[Li005]: no definition for "_nvic_int_init(unsigned long, unsigned long, unsigned long)"

0 Kudos

844 Views
c0170
Senior Contributor III

Hello Oliver Sedlacek,

please drag the library to your project. I created a couple of projects which had Additional libraries empty, a library file (*.a) was part of the project as code/header files. Does linker find the definition then?

Regards,

c0170

0 Kudos

844 Views
OliverSedlacek
Contributor III

psp.a is part of the project but the linker still can't find _nvic_int_init :smileysad:

0 Kudos

844 Views
Martin_
NXP Employee
NXP Employee

Oliver, can you post here your project ? I will try to build it on my PC. I guess you don't want to share your proprietary code, but if you could delete some confidential parts of your application to a bare minimum (like hello world), just to reproduce the issue on my side.

0 Kudos

845 Views
OliverSedlacek
Contributor III

OK, so thanks to efforts from by software buddy I can report that the reason why the linker couldn't link to _bsp_int_init despite it being in bsp.a was due to C++ name mangling. Obvious when you know.

0 Kudos

845 Views
patrikčižmár
Contributor II

"OK, so thanks to efforts from by software buddy I can report that the reason why the linker couldn't link to _bsp_int_init despite it being in bsp.a was due to C++ name mangling. Obvious when you know."

Ok but how did you resolve it anyway ? How did you resolve the C++ name mangling ?

0 Kudos

844 Views
OliverSedlacek
Contributor III

As the _bsp_int_init() function is in a C function library, you need to tell the linker to expect an unmangled name. You can do this as follows:

#ifdef __cplusplus

extern "C" {

#endif

#include "some c file headers"

#ifdef __cplusplus

}

#endif



0 Kudos

844 Views
patrikčižmár
Contributor II

Thank you :-)

You just made my day :-)

It`s working now.

0 Kudos

844 Views
OliverSedlacek
Contributor III

I'll have to ask whether I'm allowed to do that...

0 Kudos