AnsweredAssumed Answered

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

Question asked by sleziak.marcin on Sep 11, 2015
Latest reply on Sep 12, 2015 by Clive One
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