The problem is that it doesn't setup the contents of reg_val32, and so while it provides A directly as the value to be written, whatever was hanging around in reg_val32 before will have the upper three bytes written.
Solution is to initialise the upper 3 bytes of reg_val32 with X, Y, Z.
The problem is that it doesn't setup the contents of reg_val32, and so while it provides A directly as the value to be written, whatever was hanging around in reg_val32 before will have the upper three bytes written.
Solution is to initialise the upper 3 bytes of reg_val32 with X, Y, Z.