cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to get SPI slave transmit working in interrupt mode

GdubeyJi
Associate

I took SPI interrupt example from STM32CubeF1 repo. I have two Nucleo-F103RB boards. I am using one board as Master and the other as Slave. If I run the example as is then communication is working as expected. That is data from Master is getting sent to Slave and Slave is able to send data back. However, the data in this example is predefined (already populated in Tx buffer). For my use case I would want to do the following…

  1. Send a variable length of command from Master
  2. Firstly receive the command at Slave, process it and then reply accordingly
  3. This whole logic should be active all the time but non-blocking

I want to get this working in interrupt mode and not in polling or DMA mode.

I can receive the data at Slave and the interrupt handler is getting called. In the interrupt handler I am populating the transmit buffer. However, the data is not getting transmitted to the Master.

I connected a logic analyzer to the SPI lines. I am sending dummy clock cycles from the master for receiving the data from slave but the data on MISO pin is not the one which was populated in the Tx buffer of Slave.

On further investigation I found that the SPI peripheral is in HAL_SPI_STATE_BUSY_RX state, even though the receive is completed and callback is received. Why after data reception complete SPI peripheral is still in busy state? How do we get out of this busy state? Do we have to clear any flags in the receive callback?

0 REPLIES 0