This probably varies according to which register you are talking about, but the vast majority of them read as zero and ignore writes.
However, best practice when updating only some of the bits in a register is to use the set/clear/xor aliases, most easily accessed via the SDK functions hw_set_bits(), hw_clear_bits(), hw_write_masked().
Although these are presented as functions, they will inline and compile away to almost nothing - hw_set_bits()/hw_clear_bits() turn into a single register write at a 'special' address, so no overhead at all, and hw_write_masked() turns into two writes so again minimal overhead - less code and safer from a concurrency point of view than writing explicit code to read/modify/write.
However, best practice when updating only some of the bits in a register is to use the set/clear/xor aliases, most easily accessed via the SDK functions hw_set_bits(), hw_clear_bits(), hw_write_masked().
Although these are presented as functions, they will inline and compile away to almost nothing - hw_set_bits()/hw_clear_bits() turn into a single register write at a 'special' address, so no overhead at all, and hw_write_masked() turns into two writes so again minimal overhead - less code and safer from a concurrency point of view than writing explicit code to read/modify/write.
Statistics: Posted by arg001 — Fri Dec 13, 2024 3:27 pm