MQXLite Semaphore issue in an interrupt

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

MQXLite Semaphore issue in an interrupt

1,017 Views
anthonyduhamel
NXP Employee
NXP Employee

Hello guys,

I'm facing an issue using MQXLite. My project runs on CW10.6 +  PEx + MQXLite.

I'm calling  "_lwsem_post" in an interrupt handler to synchronize a task with this ISR but my program goes in HardFault. I well initialized the semaphore and it is valid before calling the "post" method. The fault comes in the "lwsem.c" file just at the "_INT_ENABLE" line.

pastedImage_1.png

So.... well, enabling/disabling the interrupts in an interrupt does not sound good, but that normally the usual purpose of the semaphores.

Does anybody got the answer?

Thank you,

Anthony

0 Kudos
Reply
2 Replies

803 Views
DavidS
NXP Employee
NXP Employee

Hi Anthony,

You should be able to call the _lwsem_post() from ISR OK.

Have you checked your task stack size to ensure it is not overflowing.

Are there any ISR's in the system that are enabled but not initialized yet?

Is your LWSEM_STRUCT_PTR a global variable?  

Regards,

David 

0 Kudos
Reply

803 Views
anthonyduhamel
NXP Employee
NXP Employee

Hi David,

My semaphore is a global variablepastedImage_3.png and initialized is my init_task.

There is no task in overflow.

pastedImage_1.png

Is is valid when the ISR occurs.

pastedImage_4.png

My task I called  "Door" is waiting for the semaphore.

pastedImage_2.png

And all the enabled ISRs would be initialized. I have removed the semaphore and replaced it by a simple variable (_b_IsMoved) and it works. But it is not memory safe when you deal with several threads....

I also tried the semaphore out of the ISR, and it works. So my issue is probably ISR dependent.

I can share the source code if you want to take a look at.

Thank you,

Anthony

0 Kudos
Reply