KL27z: SPI slave may skip msb of byte to transmit

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

KL27z: SPI slave may skip msb of byte to transmit

1,029 Views
gartin
Contributor I

Hi

I have the spi slave initialized and configure to generate interrupts on kSPI_RxFullAndModfInterruptEnable which works so far. If I load the tx register with one byte (lets name it tx1) and the master initiates a one byte transfer, he receives tx1. Now if I load another byte (tx2) into the tx register, this time in the rxfull-interrupt handler (based on the previous received byte/command), the msb of this byte tx2 got skipped. So if tx2 is 0xFF, 0x7F is transmitted.

The same applies to if I start a dma transfer in the rxfull-interrupt. the msb of the first byte got skipped.

It's always the msb regardless of the msb-/lsb-first setting of the spi unit.

Is this a know behavior or is there a fundamental error in my code?

Labels (1)
0 Kudos
3 Replies

818 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gartin,

   Normally, when customer meet the SPI problem, it's better to check the SPI bus wave at first.

   You said, when your SPI master send the tx2, but the slave always can't receive the MSB.

   So, please use the logic analyzer or the oscilloscope to check the SPI bus at first, check MOSI data, whether it send out the correct data? If the SPI bus data is correct, then the problem is in the slave code side, you need to check the code and the register.

   After you test the SPI wave, if the data is correct, please send me the SPI wave.

   Actually, our SDK code SPI project already have the slave code, you can refer to the official code, which can be downloaded from this link:

Welcome | MCUXpresso SDK Builder 

The spi slave code folder: SDK_2.3.0_FRDM-KL27Z\boards\frdmkl27z\driver_examples\spi\polling_b2b_transfer\slave

Wish it helps you!

If you still have question about it, please kindly let me know.


Have a great day,
Kerry

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

0 Kudos

818 Views
gartin
Contributor I

Hi Kerry

Thanks for your answer.

You said, when your SPI master send the tx2, but the slave always can't receive the MSB.

No, it's the opposite, during the spi transfer, the slave sends out tx2 but then, the MSB is missing.

Because of these troubles I encountered, I changed the protocol a little bit so I'm not sure if I can easily reproduce it to capture it with a scope. furthermore atm I simply don't have the time :smileysad:. Maybe I'll coma back in a couple of weeks as I may have to change the protocol again in the future...

thanks

0 Kudos

818 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gartin,

   It doesn't matter, actually, KL series SPI is not complicated, when you test it, please give me the problem SPI bus wave, it is useful to analysis the problem.

  I suggest you use the logic analyzer to check the SPI bus, it will also give the SPI bus data.


Have a great day,
Kerry

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

0 Kudos