cancel
Showing results for 
Search instead for 
Did you mean: 

Is it a good idea to continuously reconfigure SPI form 8 bit to 16 bit or vice versa since the situation demands it.

Pramod singh
Associate II

I have two peripheral where one works on 8-bit mode and the other on 16-bit mode. 

What could be the best possible solution for such situations?

5 REPLIES 5
S.Ma
Principal

I assume 2 peripheral means 2 SPI slave devices controlled by SPI Master MCU?

Use 8 bit mode to get something simple and robustly working first.

If your SPI has built-in FIFO, the difference between 8 and 16 bit transmission will be diminished.

(example on STM32L4 family).

Otherwise, reconfiguring for each addressed device is also possible, while adding complexity increases risks for bugs.

Thank you for your reply.

So basically you mean to say that, I will configure my master in 16 bit mode and use it for both the 8 and 16 bit slave if my controller supports FIFO.

However the controller i'm using is stm32f4 series

S.Ma
Principal

if SPI doesn't have FIFO, better stay in 8 bit mode for both to get started.

Unless transmitting big amount of data, or having a low SYSCLK, it should be good enough before "optimizing" such as dynamically adjusting the 8 or 16 bit mode.

by the way my controller have FIFO, I just checked it out. So what do you suggest now to do

S.Ma
Principal

if you program the SPI in 8 bit mode, a 32 bit FIFO lies between the DR and the shift register.

It means if you do a 8 bit write to DR, the fifo will store 8 bit to be "digested" into the shift register.

If you do a 16 bit DR write, it will be decomposed and queued by the FIFO as 2x8 bit to feed the shift register. you could write 3 bytes or 4 bytes at once if you'd like. With FIFO, there wouldn't be much benefits to configure the SPI in true 16 bit mode here.