Problem with timing LPSPI (i.MXRT1062)

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

Problem with timing LPSPI (i.MXRT1062)

2,023 Views
arnipol
Contributor II

I have a problem with LPSPI (i.MXRT1062). It's about starting the transmission (Master).

Starting PSC + CLOCK begins after ~ 2 us after writing data  to registry (LPSPI->TDR = data or TCR.TXMSK = 1). Is this normal behavior?

On the picture: TDR is updated with the falling edge of the yellow signal. Clock starts 2u later.

 lpspi_timing.png

Labels (1)
Tags (1)
0 Kudos
Reply
7 Replies

1,867 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi arni pol,

   Thanks for your updated information.

   In fact, the test result wave delay time is not very correct, as you know, the gpio toggle also needs time.

   About DbgConsole_TryGetchar influence your interrupt, do you try to disable it, any improvement?

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

1,867 Views
arnipol
Contributor II

Time Tlead (3)  I can decrease to few nanoseconds.

The problem is to decrease time between command putting data to SPI and  SPI_PCS.

See below on picture1 - the red 1.8us. I don't know why SPI starting sendig data so late.

Picture2 -  blue line - PCS

                                      LPSPI_WriteData(EXAMPLE_LPSPI_MASTER_BASEADDR, masterTxData[masterTxCount]);

                  yellow line ->  GPIO_PinWrite(BOARD_INITPINS_CONVST1_GPIO, BOARD_INITPINS_CONVST1_PIN, 1); // yeallow signal

pastedImage_1.png

Picture1

lpspi_cs.png

Picture2

0 Kudos
Reply

1,867 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi arni pol,

   I can understanding you now.

   Please test the following situation, whether you can decrease the time or not:

1.  LPSPI_WriteData(EXAMPLE_LPSPI_MASTER_BASEADDR, masterTxData[masterTxCount]);

  This code use the register :

LPSPI1->TDR = masterTxData[masterTxCount]);

2. You can set more high module clock:

pastedImage_1.png

Any change or not?

This time is determined by the chip and the related core clock and module clock.

Have a great day,
Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

1,867 Views
arnipol
Contributor II
The clocks are set correctly, but I finally found a problem. Because I want only read the data from SPI,  i iniciate transmission  by setting the TCR.TXMSK bit = 1. Data is not loaded into the FIFO and the clock starts almost immediately (~ 300ns). Putting data to LPSPI-> TDR causes a much longer delay.
The second problem was delay of port interruption in wich I started the spi clock.
 Although the interruption had the highest priority, the delay of two microseconds still occurred.
The problem was cased by debug console, function DbgConsole_TryGetchar(in main loop)    which blocks all interruptions  by ~2us. Is' it necesery to blocked all interruption? I understand that it protects it's own  resources but sometimes causes the other problems (like in my case).
Anyway, thank You for your help.
Best regards,
Arkadiusz Polak
0 Kudos
Reply

1,867 Views
arnipol
Contributor II

The yellow signal comes from the ADC converter and triggers the interruption. Inside the interruption, the lpspi clock is initialized to receive data for the next int.

I have checked nxp sample. A little changes i've made are: increase clock to 20Mhz  and insert the <pin triger>

....

/*Fill up the TX data in FIFO */
while ((LPSPI_GetTxFifoCount(EXAMPLE_LPSPI_MASTER_BASEADDR) < g_masterFifoSize) &&
(masterTxCount - masterRxCount < g_masterFifoSize))
{

/*Write the word to TX register*/

LPSPI_WriteData(EXAMPLE_LPSPI_MASTER_BASEADDR, masterTxData[masterTxCount]);

GPIO_PinWrite(BOARD_INITPINS_CONVST1_GPIO, BOARD_INITPINS_CONVST1_PIN, 1); // yeallow signal


++masterTxCount;

.....

Time between between LPSPI_WriteData and LPSPI_CS is about 1.8 us. Is't possible to decrease it?

Clock start's more late,  but this is due to wrong calculatin of delay (in SDK 2.7) 

lpspi_cs.png

lpspi_cs.png

0 Kudos
Reply

1,867 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi arni pol,

  Could you please also add the SPI_CS pin? Do you have more channels in your oscilloscope?

  Do you want to decrease the time between the SPI_CS and the CLK ?

  pastedImage_1.png

   Do you want to decrease the item 3 time?

  

Have a great day,
Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

1,867 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi arni pol,

  Please tell me yellow signal is what in your picture ? LPSPI_CS?

 Do you test the SDK code, eg:

SDK_2.7.0_EVK-MIMXRT1060\boards\evkmimxrt1060\driver_examples\lpspi

 The same wave?

  Please tell me your wave signal in your picture at first, then test the SDK code SPI wave, then I can help you to check more details.

Wish it helps you!

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

 

Have a great day,
Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply