Can not read from SPI Rx buffer (STM32f103C8T6)

Discussion in 'Programmer's Corner' started by GergoT, Nov 1, 2017.

  1. GergoT

    Thread Starter New Member

    Jul 24, 2017
    8
    0
    Hey guys!
    I have an STM32 micro as a slave device, and I am communicating with a slave chip through the SPI interface. It works well, so far I can read from the slave's memory cells, I can see the answer on the oscilloscope. But somehow I'm not able to read out this data from the buffer. Here is the code, I hope somebody can see what I'm missing. I put it in a loop, which quits when theres any data.

    Képkivágás.PNG
     
    Last edited by a moderator: Nov 2, 2017
  2. GergoT

    Thread Starter New Member

    Jul 24, 2017
    8
    0
    Late Edit!! Terribly sorry, the STM32 microcontroller is Master, not Slave!
     
  3. MrChips

    Moderator

    Oct 2, 2009
    18,463
    5,856
    Have you initialized all of the related hardware modules correctly?
    I see that you are writing directly to hardware registers. Is there a reason for doing this rather than using a peripheral library function?
     
  4. GergoT

    Thread Starter New Member

    Jul 24, 2017
    8
    0
    It's already solved. Yes I initialized it correctly. The problem was, that one have to read from the SPI->DR register even before the last transfer, in order to clear the overflow flag, so it will receive more data. Otherwise it wont.

    Well, I use Standard Peripheral Library, and the function for transfering data contains simply a write to the SPI->DR data register only. So I could just go with this as well.
     
Loading...