spi driver crash in KSDK_1.3.0

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

spi driver crash in KSDK_1.3.0

Jump to solution
1,907 Views
keetle
Contributor III

I am testing K64 spi module in KSDK_1.3.0 and KDS3.0.

 

I do like this:

 

uint32_t Spi_Init(void)

{

     .......                                                                                                                                                  // init mux pin, variable  etc.

 

     _int_install_isr(SPI0_IRQn, (INT_ISR_FPTR)SPI0_IRQHandler, NULL);

 

     DSPI_DRV_MasterInit(0, &spiBus_Status, &masterUserConfig);                                                     //return OK

        

     DSPI_DRV_MasterConfigureBus(0, &masterDevice, &calculatedBaudRate);                                   //return OK

 

     DSPI_DRV_MasterTransferBlocking(0, &masterDevice, sendBuffer, receiveBuffer, 6, 5000U);        // when the app start, it crash at here

}

 

I debug it and the app do like this:

 

when the appliaction start, it crash at "DSPI_DRV_MasterTransferBlocking".

 

the mqx issue "mqx_unhandled_interrupt" .

 

 

it crash when "OSA_SemaPost(&dspiState->irqSync)"  execute in function  "static void DSPI_DRV_MasterCompleteTransfer(uint32_t instance)";

 

what is wrong?

Labels (1)
1 Solution
1,456 Views
adriancano
NXP Employee
NXP Employee

Hi,

This is caused because you are naming your interrupt handler with the same name as the CMSIS startup code file. This does not allow MQX to install its own handler and the MQX ISR is not called when the interrupt occurs.

You can check more information regarding Interrupt handling in KSDK in the next document from colleague Jorge Gonzalez: Interrupt handling with KSDK and Kinetis Design Studio

Attached you can find an example using SPI drivers within KSDK + MQX. Please check the install interrupt function and the handler name.

I hope this information can help you.

Regards,

Adrian

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
6 Replies
1,455 Views
keetle
Contributor III

Can someone help me?:smileyhappy:

0 Kudos
Reply
1,457 Views
adriancano
NXP Employee
NXP Employee

Hi,

This is caused because you are naming your interrupt handler with the same name as the CMSIS startup code file. This does not allow MQX to install its own handler and the MQX ISR is not called when the interrupt occurs.

You can check more information regarding Interrupt handling in KSDK in the next document from colleague Jorge Gonzalez: Interrupt handling with KSDK and Kinetis Design Studio

Attached you can find an example using SPI drivers within KSDK + MQX. Please check the install interrupt function and the handler name.

I hope this information can help you.

Regards,

Adrian

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
1,455 Views
keetle
Contributor III

I checked your answer today, the application run smoothly.

Thank you! :smileyhappy:

0 Kudos
Reply
1,456 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi keetle,

- Please step  into the function of DSPI_DRV_MasterTransferBlocking(), check it will crash when run which specific code .

- And under the KSDK1.3 , there is a SPI demo about k64 , here :

  Freescale\KSDK_1.3.0\examples\frdmk64f\driver_examples\dspi

- Under the KSDK,  there also is a MQX-spi demo , please refer to :

Freescale\KSDK_1.3.0\rtos\mqx\mqx\examples\dspi

Hope it helps

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

Have a great day,

A.kce

0 Kudos
Reply
1,456 Views
keetle
Contributor III

and I finally find it go into HardFault_IRQn.

Infact I almost use KSDK1.3.0 code like I show before, all API is from offical.

the SDK I used is base on  TWR-64F120M platform and MQX,  my device is MK64FX512VLL12, is there any problem?

0 Kudos
Reply
1,456 Views
keetle
Contributor III

I follow the debug process;

when I run function  DSPI_DRV_MasterTransferBlocking(), it will invoke the IRQHandler. After SPI module finish transmittion, it invoke function OSA_SemaPost(&dspiState->irqSync) to inform main task wake up.

However , when the SPI IRQ executing OSA_SemaPost(), it crash at:

_mqx_uint _lwsem_post(  LWSEM_STRUCT_PTR sem_ptr)

{

     .....

    _INT_DISABLE();

    if ((sem_ptr->VALUE >= 0) && (_QUEUE_GET_SIZE(&sem_ptr->TD_QUEUE)))

    {

        _QUEUE_DEQUEUE(&sem_ptr->TD_QUEUE, td_ptr);

        _BACKUP_POINTER(td_ptr, TD_STRUCT, AUX_QUEUE);

        _TIME_DEQUEUE(td_ptr, kernel_data);

        td_ptr->INFO = 0; /* Signal that post is activating the task */

        _TASK_READY(td_ptr, kernel_data);

        _CHECK_RUN_SCHEDULER();                                    /* Let higher priority task run */     //my app crash here

    }

    else

    {

        ++sem_ptr->VALUE;

    } /* Endif */

    _INT_ENABLE();

     .......

}

0 Kudos
Reply