I have a chip to be read/written via SPI. Some of its registers are 8 bits, others 24 and 32. How does the SPI master (the MCU) handle these different data sizes?


It doesn't. It just works in whatever data size you tell it to.

Typically that is 8 bits, though some can work in 16 or 32 bits for increased efficiency.

To transfer 8 bits you lower SS, transfer 8 bits, then raise SS.

To transfer 24 bits you lower SS, transfer 8 bits, transfer another 8 bits, then yet another 8 bits, then finally raise SS.

enter image description here

The entire transaction of 24 bits is just a series of 8 bit transfers framed by the SS pin being low.

What you then do with those three transferred values is entirely up to you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.