[MQX on K64] post a semaphore during an interrupt creates a hardfault

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

[MQX on K64] post a semaphore during an interrupt creates a hardfault

跳至解决方案
1,041 次查看
samuelboivineau
Contributor III

Hello,

 

I have tried to use most of the project sai_demo to test the SAI peripheral, but I have been stuck for a few days by a semaphore posted during an interrupt that creates a hardfault. The target is a K64F120M.

 

In fsl_soundcard.c, the function OSA_SemaPost(&buffer->sem) is used by SND_TxCallback, called by SND_TxDmaCallback, that is called by a DMA interrupt if my understanding is correct :

- EDMA_DRV_InstallCallback(&ctrl->dma_channel, SND_TxDmaCallback, (void *)card);

 

In the MQX documentation, I don't see anything about interrupt context.

And if I follow the post of the semaphore, then the sw goes to _lwsem_post, and sees that the semaphore is at 0, and a task is waiting for it, so the task is set ready and _CHECK_RUN_SCHEDULER is called. Then I jump into my HardFault_Handler, and I got those registers :

 

r0 = 0x1

r1 = 0x2000049c

r2 = 0x1

r3 = 0x1

r12 = 0x1fff0be0

lr = 0x30ab3          => in the code of _lwsem_wait_ticks, after _sched_execute_scheduler_internal and the result.

pc = 0x4b6               => instruction "bx lr"  in _sched_execute_scheduler_internal (defined by macro as _CHECK_RUN_SCHEDULER)

psr = 0x1000000

 

So is it ok to post a semaphore inside an interrupt ?

Maybe I have a missed some configuration ?

Currently I am doing some polling but it's not the aim for a rtos ...

What is also curious is the link register with a value with 3 at the end, there is no alignement required ? It would be some register over-written by someone ? but who ? And which stack or heap would be impacted ?

 

Thanks for your help

标签 (1)
1 解答
656 次查看
keetle
Contributor III

It means that your interrup function name should not be same as the CMSIS startup code file interrupt function name.

capture201511251001251.png

so your function name "DMA0_IRQHandler" etc are illegal.

you can modify the illegal function name like this:

void MQX_DMA0_IRQHandler(void)

{

    EDMA_DRV_IRQHandler(0);

}

after that, register interrupt function

_int_install_isr(DMA0_IRQn, (INT_ISR_FPTR)MQX_DMA0_IRQHandler, NULL);

after all,  it should be OK.:smileyhappy:

在原帖中查看解决方案

0 项奖励
4 回复数
656 次查看
keetle
Contributor III

I think you have met the same doubt I have before

I hope this link page will help you.

https://community.freescale.com/thread/379827

0 项奖励
656 次查看
samuelboivineau
Contributor III

Hello,

Thanks for your answer, I've looked at the link, but I am using the irq functions of the example, so it doesn't seem to be an issue. And I don't see how can I change it. They are defined this way :

// DMA (0 to 15)

void DMA0_IRQHandler(void)

{

    EDMA_DRV_IRQHandler(0);

} [...]

// SAI

void I2S0_Tx_IRQHandler(void)

{

    SAI_DRV_TxIRQHandler(0U);

}

void I2S0_Rx_IRQHandler(void)

{

    SAI_DRV_RxIRQHandler(0U);

}

If anyone has an idea, let me know !

Regards

0 项奖励
657 次查看
keetle
Contributor III

It means that your interrup function name should not be same as the CMSIS startup code file interrupt function name.

capture201511251001251.png

so your function name "DMA0_IRQHandler" etc are illegal.

you can modify the illegal function name like this:

void MQX_DMA0_IRQHandler(void)

{

    EDMA_DRV_IRQHandler(0);

}

after that, register interrupt function

_int_install_isr(DMA0_IRQn, (INT_ISR_FPTR)MQX_DMA0_IRQHandler, NULL);

after all,  it should be OK.:smileyhappy:

0 项奖励
654 次查看
samuelboivineau
Contributor III

Hello,

Your solution solved the issue. Thanks a lot !

0 项奖励