cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f072rbt6 discovery board spi issue

Sudharshan
Associate II

Hello everyone,

I am working with the STM32F072RBT6 Discovery board, where the board is configured as an SPI slave while another device acts as the master. I am utilizing DMA to receive and transmit data through two SPI interfaces (SPI1 and SPI2).

Currently, I have successfully implemented data reception and transmission, but I am experiencing a continuous shift in the transmitted and received data. My goal is to achieve simultaneous data reception and transmission using DMA. The communication is initiated by the master when the CS (Chip Select) pin transitions from high to low.

My questions are:

  1. Is it possible to receive and transmit data simultaneously using DMA in SPI on the STM32F072RBT6?
  2. What strategies or configurations should I consider to prevent the shifting of data in the transmission and reception process?

Any insights or solutions would be greatly appreciated!

Thank you!

1 REPLY 1
TDK
Guru

Data gets loaded into SPI before it gets shifted out. If you have the right data loaded when the master starts clocking, it will get sent out.

With DMA, it is constantly loading data. So if you try to change the next byte that will be sent, it is already too late as it's already been sent to the SPI. You can't change it anymore.

If clock rate is slow enough, you can use interrupts instead and respond quickly to change the next byte being sent, but this is difficult at high speeds. Or if you have some agreed-upon delay between transactions, you can get the data ready while the CS line is high and send it to the SPI before the master pulls CS low and starts clocking.

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