it is said access 32bit variable on 32bit architecure mcu or access 16bit variable on 16bit architecure,both are atomic.
suppose I want access memeber of structure, like
It’s still a native 32/16 bit access and should be ok. Organizing variables in a struct doesn’t matter.
It might be different for special cases where a struct is not natively aligned or if it’s tagged with a non-default alignment attribute (e.g. packed) or if members are tagged individually with non-default alignment attributes. In this cases it depends on the binary layout of the struct and/or the capabilities of the MCU.
And it’s good style to format code as code in posts (using the </> button) for better readabilty
I will mention that most 32 bit processors have instructions that can access 8 or 16 bit locations atomically, but there can be some that don’t, (or with options like packed, the compiler doesn’t use them).
One other thing to point out, since the structures or members weren’t declared volatile, the compiler is allowed to reorder the writing to the various members if it wants to. Also, while each individual write will be atomic (i.e. you will always read either the old value or the new value, never some mix of the two), it is NOT atomic as a set, another task might see the first members updated and later members not, so the members were updated atomically, but the structures are not.