cancel
Showing results for 
Search instead for 
Did you mean: 

memcpy in ISR Context when another memcpy() was already running on main thread or another ISR

pranjalk197
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Yes, it's thread safe. The operations are independent, there is no shared configuration data or internal state to worry about.

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

View solution in original post

2 REPLIES 2
TDK
Guru

Yes, it's thread safe. The operations are independent, there is no shared configuration data or internal state to worry about.

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

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..