2026-01-16 5:03 AM - edited 2026-01-16 5:09 AM
Hi!
I have the following code:
uint32_t currentTicks;
do
{
currentTicks = handle->controlData.ticks; // controlData.ticks is volatile
// copy a lot of data from handle->controlData
...
} while(currentTicks != handle->controlData.ticks);handle->controlData.ticks (and the other data fields) are regularly updated, triggered by an interrupt, which could happen during copying of this data. The idea is that if the while check is false, just copy all the data again, since during the previous copying of said data new data must have arrived and the copied data would therefore be inconsistent.
We are running on an STM32H7 and the data is in DTCMRAM
For this to work, is a Memory barrier instruction required or could there be any other pitfalls?
2026-01-16 7:21 AM
Declaring it (and the data) as volatile is enough here, no other issues.