The general advice is not to use memcpy for hardware peripheral registers or volatile qualified objects in general, even iff , they occupy an area without memory. Usually they need a specific access pattern memcpy does not guarantee. This includes using optimized wider gears, accessing the same location at the same time, or changing access order.
For reasons above and below, don't even think about dropping the volatile qualifier! The compiler can optimize the call very well (for example, if you have two identical calls without changes in the source and intermediate channels), combine the two accesses or move the call before / after another access to the hardware.
Instead, write your own copy function / loop, keeping the qualifier. This will cause the compiler to generate code that does exactly what you want. Remember to use the correct type for pointers to copies. Also note that standard integer types are not a good choice for hardware registers of a certain size. Use fixed-width types from stdint.h like uint8_t , uint16_t , ... instead.
source share