2024-08-12 03:25 AM
Is it safe to use memcpy() in an ISR when another memcpy() was already running on main thread or another ISR?
I am getting conflicting info on web about using memcpy() in an ISR to copy data between two uint32_t buffers.
MCU: STM32H723
CubeIDE V: 1.16.0
Solved! Go to Solution.
2024-08-12 04:34 AM
Yes, it's thread safe. The operations are independent, there is no shared configuration data or internal state to worry about.
2024-08-12 04:34 AM
Yes, it's thread safe. The operations are independent, there is no shared configuration data or internal state to worry about.
2024-08-12 04:52 AM
The problem would come if the structure ends up with partially old data and partially new data.
In RTOS systems you might want to lock the operations with a semaphore or mutex, so you can recover content in a more atomic fashion.