KL02 SPI transmit error when using IO as CS pin

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

KL02 SPI transmit error when using IO as CS pin

1,111 Views
kehanqin-b46569
NXP Employee
NXP Employee

Hi experts

 

My Customer now using KL02 as a SPI master device in a BMS project, and the slave device which require keep cs pin low all the time during the data transmission otherwise it may lost data.

Our KL02 SPI auto SS function will pull high the cs pin after each byte transmit, so they cannot accept. then we use the PTA5 as GPIO to control the CS pin.

But we met strange issue:

We did our test based on two FRDM-KL02 and KSDK SPI polling sample code.

Just as normal SPI usage, after the basic configure, I pull low the CS pin before the data transmit, pull high after it finished. But I don't know why the destBuff would get an extra "0x00", then it made all data in wrong order.

1.png  

2.png

 

we checked the waveform, didn't find any issues.

(pic is not clear, yellow line is CS, green line is clock, blue line is data.)

4.png

I use the blocking transfer directly, add GPIO operation.

7.png

 

configure spi SS function.

9.png

 

/*******************************************************************************************************************************/

But if I simulate GPIO as the auto-ss function, pull high every time after byte transmission, it could work.

3.png

Pull high CS every time.

8.png

6.png

 

So, can KL02 keep CS low during data transmission which size larger than 1 byte? or it must be pulled high after each bytes transmit? it couldn't be. Anything I missed?

Please help on it, thanks a lot!

0 Kudos
1 Reply

932 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi K.h.Qin,

     Please modify the master and the slave CPHA to 1, then the problem will be solved.

   1. Modify the master clock phase to 1.

pastedImage_1.png

2. Modify the slave clock phase to 1

pastedImage_2.png

3. Test it.

The SPI wave is:

pastedImage_3.png

The Master printf data is:

pastedImage_4.png

About the reason, you can find it from the KL02 reference manual:

pastedImage_5.png

pastedImage_6.png

So, when use the GPIO as the CS, please use the default CPHA=1.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos