Arduino Forum

Products => Arduino Due => Topic started by: indeed on Apr 27, 2019, 06:20 pm

Title: Partial writes to registers
Post by: indeed on Apr 27, 2019, 06:20 pm
Most (if not all?) of the SAM3X8E's memory-mapped registers are 32-bit. However, memory accesses of size 8 and 16 bits are also supported by the CPU. I am wondering if there are any issues associated with accessing, particularly writing, registers with memory operations of a smaller size?

For example, the SPI_TDR register is 32-bit, and upon writing, triggers an SPI transfer. Would writing, say, only half the register at once with a 16-bit access exhibit well-defined behaviour? I have tried it and it does seem to work, but I'm thinking that maybe one is supposed to only write to the entire register at once, especially considering the "special" behaviour of triggering the SPI transfer.

Sorry if this is a silly/trivial question, but low-level stuff can be funky, and to me it doesn't seem impossible that there would be some such requirement on register access.
Title: Re: Partial writes to registers
Post by: ard_newbie on Apr 27, 2019, 06:28 pm

Did you read the detail of SPI_TDR on page 697 of Sam3x datasheet ?
Title: Re: Partial writes to registers
Post by: indeed on Apr 27, 2019, 06:38 pm
Yes. As far as I can see it says nothing about partial writes.