LPSPI 32bits response and Clock Configuration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPSPI 32bits response and Clock Configuration

Jump to solution
1,826 Views
Rmpr
Contributor II

Hello,

I want to communication with a sensor using the NXP S32K344 board as the master using LPSPI1. The clock for the spi communication should be 1MHz according to the sensor's datasheet. I need to send an 8bit command and should receive a 32bit response.

 

I configured the clock for 10MHz and sent the command once and in the oscilloscope everything is fine despite not having answers from the sensor. Although when I put the clock at 1MHz the master sends 2 times the command.

 

Clock at 10MHz:

Rmpr_0-1691489123841.png

Clock at 1MHz:

Rmpr_1-1691489203803.png

This is the first problem. The baudrate used for both cases is 100000.

 

I've also defined the SpiDataWidth for 32bits. But I'm not sure how to receive the 32 bits response since the RTD function used "Lpspi_Ip_SyncTransmit" has 8bits array as inputs.

My code:

Lpspi_Ip_SyncTransmit(&SPI_EXTERNAL_DEVICE, Tx_Buffer, Rx_Buffer, NUMBER_OF_BYTES, TIMEOUT);

Tx_Buffer is an uint8 and Rx_Buffer is an uint32.

 

Function Declaration:

Lpspi_Ip_StatusType Lpspi_Ip_SyncTransmit(
                                            const Lpspi_Ip_ExternalDeviceType *ExternalDevice,
                                            uint8 *TxBuffer,
                                            uint8 *RxBuffer,
                                            uint16 Length,
                                            uint32 TimeOut
                                         )

 

 

Also, if I update "Lpspi_Ip_UpdateFrameSize" for 32 bits the programm crashes.

Lpspi_Ip_UpdateFrameSize(&SPI_EXTERNAL_DEVICE, 32U);

 

Thank you.

Tags (3)
0 Kudos
Reply
1 Solution
1,790 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Rmpr

Sorry, we overloaded recently,
1. Regarding your first question, I didn't find any abnormality. This may be the reason of your sensor rather than MCU.
2. Rx_Buffer is an uint32, this is not correct, Rx_Buffer should be an 8-bit unsigned array. Secondly, the Frame size should have been set in the configuration interface.

View solution in original post

0 Kudos
Reply
2 Replies
1,791 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Rmpr

Sorry, we overloaded recently,
1. Regarding your first question, I didn't find any abnormality. This may be the reason of your sensor rather than MCU.
2. Rx_Buffer is an uint32, this is not correct, Rx_Buffer should be an 8-bit unsigned array. Secondly, the Frame size should have been set in the configuration interface.

0 Kudos
Reply
1,772 Views
Rmpr
Contributor II
Thank you, I managed to solve the problem
0 Kudos
Reply