No activity on MOSI and CS with example code on S32K344

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

No activity on MOSI and CS with example code on S32K344

Jump to solution
1,539 Views
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.

Tags (4)
0 Kudos
1 Solution
1,502 Views
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.

View solution in original post

0 Kudos
6 Replies
1,441 Views
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 Kudos
1,491 Views
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 Kudos
1,473 Views
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 Kudos
1,468 Views
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 Kudos
1,464 Views
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 Kudos
1,503 Views
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 Kudos