No activity on MOSI and CS with example code on S32K344

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

No activity on MOSI and CS with example code on S32K344

跳至解决方案
3,307 次查看
ManishKK
Contributor III

Hello,

I am unable to get the example code with LPSPI4 as the master (on NxP S32K344 - MR-CANHUB) and Aardvark SPI adapter as the slave. The baudrate is configured as 8Mhz. Clock measurement on Saleae does show that as 8 Mhz.

I have tried all possible configurations to make sure that CS and MOSI show some activity. However, I am unable to get it to work.

See attached snapshot of saleae. Also code is attached.

This is on FreeRTOS with RTD drivers.

标记 (4)
0 项奖励
回复
1 解答
3,270 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@ManishKK

I made some modifications to your code and the test results are as follows.

Senlent_0-1698650686522.png

Your pin configuration is wrong and I lowered the communication rate so that  I can test.

在原帖中查看解决方案

0 项奖励
回复
6 回复数
3,209 次查看
ManishKK
Contributor III

Thanks Senlent. It worked. I had a loose connection (an alligator clip tapping on to MISO and CS lines that were taped).

 

0 项奖励
回复
3,259 次查看
ManishKK
Contributor III

Thanks Senlet. After making the pin configuration change, I see that CS is always low (and is not toggling). Also for me MOSI is always HIGH. In your case, it is all 0's. I am trying to send the following data over MOSI lines - {1, 2, ..., 10}. I dont see that on MOSI.

And I am unable to change the FreeRTOS clock to 120000000. Is that necessary for LPSPI to work properly?

I am attaching my changes.

0 项奖励
回复
3,241 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@MainshKK

This is the demo you provided and I have not made any modifications .

The test results are as follows:

Senlent_0-1698732889909.png

You can see that as the master side, the data sent by the MCU is normal, and the MOSI should be controlled by the slave side, if there is no data, I think you should fine the problem on the slave side.

In addition, the above test hardware is based on the mini-board, and all IO ports are directly connected to the logic analyzer.

 

0 项奖励
回复
3,236 次查看
ManishKK
Contributor III

You mean MISO should be controlled by the slave.

It is unfortunate that the schematic of the MRCANHUB board refers to SIN as MOSI and SOUT as MISO. However, S32K pins refer to SIN as input and SOUT as output. This has caused a lot of confusion on my side.

This is what my understanding is regarding SIN and SOUT? Please correct me, if that is wrong:

SIN - Input to the SPI entity (master or slave)

SOUT - Output from the SPI entity (master or slave)

So, if S32K344 acts as the Master, SIN should be connected to SOUT of the slave, which means it acts as MISO on the master side.

Similarly, SOUT of the S32K344 should be connected to the SIN of the slave, which means S32K's SOUT pin acts as MOSI.

Finally, for some reason - I either see CS being low or high all the time even when I have the setting to be CS_TOGGLE instead of CS_KEEP_ASSERTED. And in both scenarios S32K is able to communicate with the slave.

Also, with the SPI_DATA_WIDTH set to 8 bits, I see the that at 8Khz, S32K as a master spits out only 4 bytes to which the slave responds by sending 4 bytes.

However, at 4Khz more than 4 bytes are sent out (for example 7 bytes) and the slave responds with the same number of bytes.

0 项奖励
回复
3,232 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@ManishKK

1.very easy to understanding,

Senlent_0-1698735650105.png

Senlent_1-1698735705469.png

2.From the screenshot I sent you, you can see that the CS pin works exactly as expected.

If your CS pin has not changed, I think you can check the hardware of this pin.
What I can help you do is troubleshoot your software problems. I can't help you troubleshoot other problems. We don't have CANHUB hardware.

0 项奖励
回复
3,271 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@ManishKK

I made some modifications to your code and the test results are as follows.

Senlent_0-1698650686522.png

Your pin configuration is wrong and I lowered the communication rate so that  I can test.

0 项奖励
回复