Skip to main content
JDela.1
Associate II
July 1, 2021
Question

I use SPI as MASTER half duplex mode. I suppose to receive data I need to put SPI as receiver and send dummy byte to generate clock to receive byte from peripheral. Could you confirm I have correct understanding ?

  • July 1, 2021
  • 6 replies
  • 4788 views

..

    This topic has been closed for replies.

    6 replies

    CPINA
    ST Employee
    July 6, 2021

    Hello,

    Is your SPI is running in receiver mode only (RXONLY) or do you need to use it in real half duplex mode (transmitting some time and receiving sometimes too .. ? Please could you tell me which MCU you are using ?

    CPINA
    ST Employee
    July 6, 2021

    But yes I presume you need to write a Dummy data to SPI TX FIFO as master to generate the clock, each time you need to receive data from the slave in Half duplex mode. For sure, the slave needs to be ready to send the data before receiving the clock by the master.

    BR

    JDela.1
    JDela.1Author
    Associate II
    July 6, 2021

    Hi CPINA.

    Thank you for your help.

    I use STM8L152C6.

    In fact in paralle I have found the reference manual applicable for this µP (cd00218714).

    So I was wrong but I have my response to use SPI as Master in simplex communication mode with BDM=1 and direction selected by BDOE.

    Nevertheless, that is not fully clear for me is the correct condition to stop RX to avoid extra clock. I have understood that setting SPE starts SPI clock. But on which event I can clear SPE to stop clock at good time. Signal RXNE seems good signal but I need to manage under interrupt or poll on this signal. Could you confirm my approach or is there another way ?

    Thank you in advance for your support.

    BR

    CPINA
    ST Employee
    July 7, 2021

    Hello,

    So if I summarize, you are master with your SPI in half duplex mode using BDM and BDOE to change direction. It looks like the procedure to STOP the SPI In RX is the same as for master RXONLY (unidirectional line). as described in page 575 of the reference manual.0693W00000Bd1kgQAB.jpg 

    It is easiest for the TX Mode, since the clock is stopped when the TX buffer is empty. It is only need to check the TXE and the BSY=0 to stop the SPI.

    Hope it helps,

    Best regards,

    JDela.1
    JDela.1Author
    Associate II
    July 7, 2021

    Thanks a lot.

    All is fine.

    BR

    CPINA
    ST Employee
    July 7, 2021

    Welcome !

    Have a nice summer !

    In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'