cancel
Showing results for 
Search instead for 
Did you mean: 

What is the fastest way to manage slave select manually when trying to send 32 bit data over 16 bit SPI with DMA (STM32WB55)?

SStoy.1
Associate II

Hi,

I'm trying to send 32 bit data with DMA over SPI to a slave device with the STM32WB55 which can only be configured to use hardware NSS with 16 bit transfers at most. I understand that I will likely have to pull the chip select down manually, send 16 bits twice consecutively, and then pull the chip select up and repeat. I would have liked to be able to do this automatically without wasting any time as I will be sending a continuous stream of data. However, if I understand correctly, this cannot be done by hardware for the 32 bit case. I am wondering if there is a fast way to do this without constantly polling a flag or something like that as I also want to send the data received back over bluetooth. Any advice/ thoughts would be much appreciated.

Thanks,

SS

1 REPLY 1
TDK
Guru

If you initiate each transfer, set up a timer in one pulse mode and use one channel to act as the CS signal. Activate the timer just prior to sending data on SPI. If configured correctly (right period/polarity/settings), it will deactivate at the end of the transfer.

To send 32 bits of data, since there is a TXFIFO which can accommodate 32 bits, set it to 8-bit or 16-bit word mode and then write all 32-bits to the DR register. The FIFO will send them out automatically one after the other. (Even if there wasn't a FIFO, you could write 2 16-bit words immediately since the first would be immediately sent to the shift register, generate TXE, and free up the register.)

If you feel a post has answered your question, please click "Accept as Solution".