S32K144EVB: SPI Clock Not Accurate

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

S32K144EVB: SPI Clock Not Accurate

1,624 Views
mahmoudsherrah
Contributor III

My SPI driver on S32K144EVB-Q100 is working. However, as SPI master, the output master clock is not very accurate.

- The SysClock is 80MHz (normal run mode)

- I set LPSPI0 input clock to SPLLDIV2  which sets LPSPI0 functional clock it to 40MHz

- I set PRESCALE in LPSPI0->TCR to 0 (divided by 1), so SPI clock is still 40MHz

- I set SCKDIV in LPSPI0->CCR to 1 (1 + 2(mandatory) = 3), so SPI clock is 40MHz/3 = 13.3MHz

I observe the output clock using a 250Ms/S PC-based oscilloscope (Saleae) and the clock is not exactly 13.3MHz.

In one transmission it is ~12.5MHz, in the next transmission it is ~13.1MHz. It is never constant and it is never exactly 13.3MHz.

My question is: is this a common attribute of SPI clocks in general? is there always a margin of error that is unavoidable? Or is it a problem of 13.3MHz not being a whole number (like 8MHz or 4MHz.. etc)?

Labels (1)
0 Kudos
4 Replies

1,100 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,
I would use an oscilloscope instead of the logic analyzer for precise measurements at higher frequencies.
Do you supply the MCU with 5V or 3V3?
Please refer to Table 31, LPSPI electrical specifications, S32K1xx Datasheet, rev. 7.
14MHz is max SPI baud rate at 3V3 VDD in HSRUN.
Please use GPIO-HD pins (specified in S32K144 IO_Signal_Description_Input_Multiplexing.xlsx) and set PCR_DSE = 1.
These pins have faster slew rate.

Regards,
Daniel

0 Kudos

1,100 Views
mahmoudsherrah
Contributor III

Hello again Daniel,

I have referred to the datasheet, LPSPI electrical specifications table and I have some questions:

1- Do you have an idea what is the difference between "Peripheral Frequency" and "Frequency of Operation" on the 1st and 2nd rows respectively?

2- Does it also mean that the maximum achievable throughput is 14MHz in HSRUN? All I need is to acheive 20MHz SPI transfer rate. Is this possible (specially that "Peripheral Frequency" can go up to 56MHz in HSRUN

3- I also noticed that there is no difference in frequency between 5V and 3V3 modes. Is this a correct conclusion?

Your feedback is much appreciated.

0 Kudos

1,100 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Please see Table 49-5, RM rev.7.
Functional clock = Peripheral Frequency
External clock = Frequency of Operation = baudrate

Yes, it is 14MHz in HSRUN at 3V3.
Yes, the peripheral frequency (internal frequency) is the same both at 5V and 3V3.

Regards,
Daniel

0 Kudos

1,100 Views
mahmoudsherrah
Contributor III

Hi,

I do supply the MCU with 3V3. I didn't know this would be a deciding factor.

I will try what you suggested (Oscilloscope + setting PCR_DSE) and I'll get back to you.

Thanks a lot,

Mahmoud

0 Kudos