cancel
Showing results for 
Search instead for 
Did you mean: 

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

Rob Pattinson
Associate II

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?

4 REPLIES 4
TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".
Rob Pattinson
Associate II

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

Rob Pattinson
Associate II

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

> I needed to disable NSSP mode also.

Why?

JW