LPSPI clock freq and frequency of operation

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

LPSPI clock freq and frequency of operation

3,514 Views
vladdamian
Contributor I

Hello,

I am currently trying to figure out details about LPSPI and I am looking into the datasheet, but somehow I am still in doubt.

Also, because I am new on embedded world.

1.)What is the difference between peripheral LPSPI frequency (which is 56MHz in HSRUN mode) and frequency of operation (which is 24 MHz or 14 MHz, depending of which voltage you have)?

 2.)The main point is that I am trying to test the faster speed that SPI can run. 

I have tested the example code (LPSPI) and modified the sourceClock and baudRate, but all I could get was 4 MHz.

I also read in another post that for faster freq, you need to run it into DMA mode (now I am running in LPSPI_USING_INTERRUPTS mode) . I am trying to configure the DMA now, maybe I can go up with the freq.

But I would like to know why is this limitation of 4 MHz on USING_INTERRUPTS mode and also, can I go up to 24 MHz clock freq?

Thank you ! 

PS: hope that my question is not too confusing or misleading. 

Labels (1)
0 Kudos
Reply
5 Replies

2,738 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Vlad,

Sorry for the late response.

There are three clocks.

LPSPI bus interface clock is always BUS CLK gated by PCC module, see Table 27-8 RM rev12.1.

BUS CLK can be max 56MHz in HSRUN.

 

Peripheral functional clock is also configurable in PCC[PCS]. The frequency must be less or equal to BUS CLK.

Then in LPSPI module the functional frequency (56MHz) is divided using a prescaler in LPSPI[TCR] register. If set to 0, it divides the functional clock by 1 (56MHz).

 

The SPI bit rate is set by SCK divider in LPSPI[CCR] register. The division factor is equal to SCKDIV + 2. It means the bit rate can be set theoretically to 28MHz.

But as you can see in S32K DS the bit rate is limited to 14MHz in HSRUN in order to sample data coming from a slave.

Using Master loopback feature (CFGR1[SAMPLE]) which delays SCK clock for sampling the slave data, the bit rate can be set up to 24MHz provided the MCU runs at 5V power supply.

If you can set only 4MHz, you probably set something wrong. Please check all the registers mentioned above. And make sure the MCU is in HSRUN, if you use it. 

Regards,

Daniel

0 Kudos
Reply

2,738 Views
weiq
Contributor I

pastedImage_2.png

what is the different between Peripheral Frequency andFrequency of operation or what do they mean?

0 Kudos
Reply

2,739 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi weiq@stec-cn.com,

The Frequency of operation is the bit rate on the SPI bus.

Peripheral frequency:

pastedImage_2.png

pastedImage_3.png

Regards,

Daniel

0 Kudos
Reply

2,739 Views
weiq
Contributor I

The Frequency of operation is the bit rate on the SPI bus. I see max Frequency of operation is 10MHZ。Is meaning that SPI bit rate max is 10MHZ?but why  LPSPI the bit rate can be set up to 24MHz 

0 Kudos
Reply

2,739 Views
danielmartynek
NXP TechSupport
NXP TechSupport

It can be 24MHz in HSRUN mode if the loopback feature is enabled.

In RUN mode without the loopback mode, the bit rate can be up to 10MHz only.

 

Regards,

Daniel

0 Kudos
Reply