Skip to main content
HYoun
Associate II
August 18, 2020
Solved

Request technical support for SPI communication between STMicroelectronics Nucreo F401RE board and tpm module.

  • August 18, 2020
  • 2 replies
  • 1413 views

I coding in C/C++, and using SPI function through 'HAL_SPI_Transmit' and 'HAL_SPI_Receive'.

TPM module send me only 'ff ff ff ff ... ff ff'.

i see the tpm module's manual, but i can't understand.

plz, tell me a few example code.​

This topic has been closed for replies.
Best answer by Jack Peacock_2

Look at the timing diagram for your TPM module, in particular the clock edge used to clock in/out data. If you are only receiving 0xFF that's an indication you are either reading back data on the wrong clock edge, or writing data to the TPM on the wrong edge. This affects CPOL and CPHA.

Also, does the TPM receive and send back data at the same time (i.e. full duplex) rather than write command followed by read response (half duplex)?

Jack Peacock

2 replies

TDK
August 18, 2020
"If you feel a post has answered your question, please click ""Accept as Solution""."
HYoun
HYounAuthor
Associate II
August 19, 2020

Thank you for your reply, TDK!

I entered in that link,

but actually my key question is

'how to set data field to send TPM module through SPI function'

I set environment like this:

  1. SPI Baudrate : 16
  2. CPOL : HIGH
  3. CPHA : 1EDGE

The above settings were made because it was recognized as necessary for 'spi communication' with the TPM.

​It would be a hassle, but I'd appreciate your re-re-reply.

Thank you.​

TDK
August 19, 2020

I don't really want to write code for you.

Look at the example code, try it, make sure you understand what's happening.

If you are still stuck, show what you've tried. Show your code in your post so we have something to go off of.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Jack Peacock_2
Jack Peacock_2Best answer
Associate II
August 19, 2020

Look at the timing diagram for your TPM module, in particular the clock edge used to clock in/out data. If you are only receiving 0xFF that's an indication you are either reading back data on the wrong clock edge, or writing data to the TPM on the wrong edge. This affects CPOL and CPHA.

Also, does the TPM receive and send back data at the same time (i.e. full duplex) rather than write command followed by read response (half duplex)?

Jack Peacock

HYoun
HYounAuthor
Associate II
August 20, 2020

Thank you for your reply, Jack Peacock_2!

As far as I know, full-duplex is impossible for TPM modules.

So, i set my MASTER node to half-duplex.​

I think, data is wrong, When I send to SLAVE(TPM).

I send data like this :

char data[] = "0111111100011010000110000010000012345678901234567890123456789012";

Above data's set is reference to below paper (135 page):

https://trustedcomputinggroup.org/wp-content/uploads/PC-Client-Specific-Platform-TPM-Profile-for-TPM-2p0-v1p04_r0p37_pub-1.pdf

​​It would be a hassle, but I'd appreciate your reply.

Thank you.​

HYoun​