SPI sck strange behavior

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

SPI sck strange behavior

Jump to solution
1,168 Views
tapiepierre
Contributor III

Hello Freescale community,

 

I use Kinetis Design studio 2.0.0, MQX KSDK 1.0.0 with Processor expert, (uc MK64F),

 

I realized SPI communication  using SPI0 and two channels DMA for Tx et Rx. I talk with a multiports (ADC,DAC, GPI,GPO) component at 4MHz.

 

I chose sck non-continuous for the configuration of the SPI

 

The frame format is 3 bytes : One for CMD, one for data LSB and one for data MSB.

 

I have a problem with reception of the first bit of each new byte because the sck signal has a strange behavior : the gap between two clock cycle is good but the gap between the 8th bit and the first bit of the next byte is different. You can see the behavior on the following screenshot :

 

40954_40954.pngSPI_Faults.png

 

with a zoom we can very well if the clock difference :

 

40955_40955.pngSPI_Faults_zoom.png

 

What the problem, Can you help me ?

 

I'am not interresting to use sck continuous mode,

 

I have found a solution for not having problem reading the first bit of new byte using functions :

 

static inline void DSPI_HAL_SetModifiedTimingFormatCmd(uint32_t baseAddr, bool enable)

and

static inline void DSPI_HAL_SetDatainSamplepointMode(uint32_t baseAddr,dspi_master_sample_point_t samplePnt) with "kDspiSckToSin_1Clock"

But signal MOSI is modify and I think this is not a properly operation

 

You can see with this modifications :

 

40956_40956.pngSPI_GOOD.png

 

Please can you give me some advices to resolve this problem ?

 

 

 

Labels (1)
1 Solution
896 Views
tapiepierre
Contributor III

Hello,

I found the solution, I use the function DSPI_DRV_MasterSetDelay with argument "kDspiPcsToSck" and I put the little delay I want between each bytes.

SPI_Good_Timing.png
     Thanks for your help
     Regards

View solution in original post

3 Replies
896 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello PE TAPIE:

If I understand correctly the time between frames is shorter than the time between bits, right?

You can try setting a delay with the API DSPI_DRV_MasterSetDelay(instance, kDspiAfterTransfer, [nanoseconds], & calculatedDelayaftertransfer). In nanoseconds you would set the time to match the time you get between bits.

I hope this helps!


Regards!,
Jorge Gonzalez

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

0 Kudos
Reply
896 Views
tapiepierre
Contributor III

Hello Jorge Gonzalez,

Thanks for your answer,

I have already use this function for apply special delay, but the delay  "kDspiAfterTransfer" allow to modify the delays between two activation of the chip select and not between the 8th bit and the first bit of the next byte.

In this image you can see the delay of 400 ns I apply :

SPI_MOD.png

But my problem is still present,

you have very well understood my problem : the time between Byte is shorter than the time between bits ,

Please help me ?
0 Kudos
Reply
897 Views
tapiepierre
Contributor III

Hello,

I found the solution, I use the function DSPI_DRV_MasterSetDelay with argument "kDspiPcsToSck" and I put the little delay I want between each bytes.

SPI_Good_Timing.png
     Thanks for your help
     Regards