LPSPI 32bits response and Clock Configuration

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

LPSPI 32bits response and Clock Configuration

跳至解决方案
2,177 次查看
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.

标记 (3)
0 项奖励
回复
1 解答
2,141 次查看
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 项奖励
回复
2 回复数
2,142 次查看
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 项奖励
回复
2,123 次查看
Rmpr
Contributor II
Thank you, I managed to solve the problem
0 项奖励
回复