Skip to main content
Visitor II
September 8, 2020
Question

How can I create the following SPI transaction using the H7 ST HAL libraries?

  • September 8, 2020
  • 4 replies
  • 998 views

The transmit command only clocks out the provided data and then the clock stops, I need it to continue for 8 dummy clocks before doing receive I think.0693W000003R6D2QAK.png

I bet there is a simple answer to this though, can you help me?

    This topic has been closed for replies.

    4 replies

    Super User
    September 8, 2020

    So the frame is 39 bits long? Or is it 40 and they just aren't showing the 39th pulse?

    If it's 40, then you just send 0x9F followed by 4 zero bytes. Presumably having DI be 0 instead of high impedance is okay. And then ignore the first 2 bytes of data you get back.

    uint8_t data[5] = {0x9F};
    HAL_SPI_TransmitReceive(&hspi, data, data, 5, HAL_DELAY_MAX);
    uint8_t mfr_id = data[2];
    uint8_t devid = data[3] << 8 + data[4];

    Did not test that code, should be close.

    Visitor II
    September 10, 2020

    Thank you TDK, I'll give this a go today! RP

    Visitor II
    September 10, 2020

    Great, that worked. I needed to disable NSSP mode also. :)

    Super User
    September 10, 2020

    > I needed to disable NSSP mode also.

    Why?

    JW