cancel
Showing results for 
Search instead for 
Did you mean: 

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

HYoun
Associate II

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.​

1 ACCEPTED SOLUTION

Accepted Solutions
Jack Peacock_2
Senior III

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

View solution in original post

6 REPLIES 6
TDK
Guru

One example:

https://github.com/STMicroelectronics/STM32CubeF4/tree/master/Projects/STM32F429I-Discovery/Examples/SPI/SPI_FullDuplex_ComPolling

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

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.​

Jack Peacock_2
Senior III

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

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".

Thank you for your re-re-reply!​

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​