Skip to main content
contact239955_st
Associate II
September 11, 2015
Question

STM32 as SPI slave -> How to send response while receiving data from master?

  • September 11, 2015
  • 1 reply
  • 864 views
Posted on September 11, 2015 at 22:26

Hi, I've been trying to create a simple communication protocol between two STM32 MCUs, I am having trouble however to respond data to the master in the spi interrupt, could someone perhaps point me in the right direction? Much appreciated

void
SPI_interrupt(
void
){
if
(SPI_I2S_GetITStatus((SPI_TypeDef *) SPI1_BASE, SPI_I2S_IT_RXNE) == SET)
{
a = SPI_I2S_ReceiveData((SPI_TypeDef *) SPI1_BASE);
SPI_I2S_SendData((SPI_TypeDef *) SPI1_BASE, 0x55);
}
}

What happens here is that the received data is correct, however the master receives 170 instead of 85 (0x55) I have attached a screenshot of my logic analyzer Kind regards, Marcin
    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    September 11, 2015
    Posted on September 12, 2015 at 01:49

    Well either a clock edge thing, or an MSB/LSB bit ordering thing.

    Try sending a 0x0F, does that look to be 0xF0 or 0x1E ?

    Perhaps your analyzer is looking at it wrong, what's actually visible at the master?

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..