cancel
Showing results for 
Search instead for 
Did you mean: 

Non-blocking Flash operations in Standard Peripheral Libraries for RTOS use

Dazai
Associate III

I inherited an old STM32 project (STM32F373) that uses FreeRTOS and the old Standard Peripheral Library (apparently v1.0.0, dated Sept 20, 2012). Among other things, the project uses USART1 with interrupts to receive LIN messages, and also has a task that runs every 10ms to check the status of input signals (buttons) and writes 3 words to the last flash page if one of them is pressed.

In the scenario where there is a lot of traffic on the LIN bus (essentially no time gaps between messages) and the button is pressed, the code repeatedly calls the USART1 ISR and nothing else can run.

I have not been able to determine why the ISR keeps getting called; I have handlers in it for each of the interrupts I have enabled, and examining the USART1 registers in debug mode did not reveal anything. That led me to consider other problems, which led to the flash operation, and I discovered the Standard Peripheral Library flash functions have blocking delays in them; if I comment out the flash operations, the code does not get stuck in the USART1 ISR.

So that was a long winded way to get to my question which is: is there a non-blocking flash implementation in the Standard Peripheral Library?  If not, is there an example of how to do flash operations with DMA and/or interrupts to make them non-blocking, using the old Standard Peripheral Library?  I am not able to update the project to HAL, which would be my preference, and I've been unable to find examples that use the Standard Peripheral Library.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Sarra.S
ST Employee

Hello @Dazai

Although I have no experience with SPL, I would try relocating the vector table to SRAM, so that interrupts can be serviced during flash operations 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Sarra.S
ST Employee

Hello @Dazai

Although I have no experience with SPL, I would try relocating the vector table to SRAM, so that interrupts can be serviced during flash operations 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.