cancel
Showing results for 
Search instead for 
Did you mean: 

__HAL_LOCK(x) function in STM32 with FreeRTOS

AShel.1
Associate III

I'm using STM32F767 and referring STM32746G-Discovery code. I've question regarding __HAL_LOCK() function. if I'm using FreeRTOS, I've created 2 threads, one to to handle QSPI interface for flash and second thread to handle CAN communication and reading ADC. if I write to block of data into flash over QSPI then HAL will be locked. will it block other interrupts too, can I read ADC in while the flash writing is going on? OR

will other functions continue to work?

2 REPLIES 2
TDK
Guru

The __HAL_LOCK only locks a peripheral at a time. If only one thread does QSPI and only one thread does CAN, you'll be fine.

Note also that __HAL_LOCK is not thread-safe, so the safe thing to do is to ensure each peripheral is only accessed by a single thread. There are other methods, but that's the most straightforward.

If you feel a post has answered your question, please click "Accept as Solution".
AShel.1
Associate III

thanks TDK

so, if I lock SPI like _HAL_LOCK(QSPI); still I'll be able to get interrupts on CAN receive pin.