FreeRTOS Support Archive

The FreeRTOS support forum can be used for active support both from Amazon Web Services
and the community. In return for using our software for
free, we request you play fair and do your bit to help others! Sign up
to receive notifications of new support topics then help where you can.

This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.

Use of ISR - STM32 - Freeze

I'm trying to use FreeRTOS 6.0.4 on an STM32F3 Discovery Board,
but I encounter some problems.

I want to give a mutex by ISR when I receive a CAN bus message, to wake up another task.
I have a second task which permit a LED to blink.

My problem is before the CAN trame is received, the program runs normally, and I see the LED blinks.
But when a CAN trame arrives, the ISR wakes up and the program blocks in it.
Tasks are stop running, and the LED stops to blink.

Sending and receiving CAN trames are working without use of ISR, only problem is when I try to use ISR.
I thought the problem is because of I set wrong priorities but it seems OK for me..

Use of ISR - STM32 - Freeze

Yikes that is an old version. Normally the advice would be to define configASSERT() to have the assert check the interrupt configuration for you - but I don't think that will help in V6.x code. That said, I cannot see anything wrong with what you have posted (thanks for posting useful information!) provided the STM32 in use has 4 priority bits defined.

Can you try changing the semaphore from a mutex to a binary semaphore. You only need change the function used to create the semaphore, nothing else. The reason being that various different FreeRTOS versions have had different rules on giving mutexes from interrupt - the reason being that mutexes use priority inheritance, which has little meaning when they are used from an interrupt. Let me know if that helps.

Regards.

Use of ISR - STM32 - Freeze

I was already using binary semaphore in my code, I was wrong when I wrote "I want to give a mutex by ISR", sorry.
I tried to comment the "void USBLPCAN1RX0IRQHandler(void)" handler, and I saw the same thing : the program froze when a CAN trame is received.

Use of ISR - STM32 - Freeze

Inside that function it is only valid for the buffer to be NULL, if zero bytes are going to be copied into the buffer (i.e. the buffer is not going to be accessed). If pxQueue->uxItemSize is zero, then no data is going to be copied to the buffer. pxQueue->uxItemSize will be zero, and pvBuffer will be NULL, if the queue is actually being used as a semaphore.

In your case it is correctly detecting that, if the assert didn't catch it, the code would attempt to write 8 bytes to a NULL pointer.

When the code stops on that line, look at the function call stack in the debugger. That should tell you the route through the code taken to get to that point, which will help you debug how it came to be.

I realized that, when CAN ITs are enabled (CANITConfig(CAN1, CANITFMP0, ENABLE);), you need to clean FIFO with CANreceive() in the IRQ (maybe I am wrong ? but this is what I'm observing).
Else program stops working at the first received message.

This problem was a STM32 functionning problem, not a freeRTOS problem.