2019-01-07 01:04 AM
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?
2019-01-07 01:12 AM
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.
2019-01-07 01:23 AM
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
2019-01-07 01:39 AM
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.
2019-01-07 01:48 AM
by the way my controller have FIFO, I just checked it out. So what do you suggest now to do
2019-01-08 12:26 PM
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.