S32K144 clock frequency question

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

S32K144 clock frequency question

1,324 Views
asd046012
Contributor III

Hello  

    

     I use the processor expert to config the working frequency of  MCU S32K144,and configured as below:use external 8MHz clock.then called the API to initial the clock as below:

void Clock_Init(void)
{
    CLOCK_SYS_Init(g_clockManConfigsArr,1,g_clockManCallbacksArr,0);
   /** in function CLOCK_SYS_UpdateConfiguration have set
   ** system clock,periperal clock,low power clock and power mode control .
   **/
    CLOCK_SYS_UpdateConfiguration(0,CLOCK_MANAGER_POLICY_AGREEMENT);
}

 after I initial the clock module,and write a test program to verfity the expected clock.the test program is as below:

void Delay_ns(void)
{
    __asm("nop");
    __asm("nop");
    __asm("nop");
    __asm("nop"); 
   __asm("nop");
  __asm("nop");
  __asm("nop");
  __asm("nop");
}

void Delay_us(void)
{
    PINS_DRV_SetPins(PTD,0x00000020);
    Delay_ns();
    Delay_ns();
    Delay_ns();
    Delay_ns();
    Delay_ns();
    Delay_ns();
    Delay_ns();
   Delay_ns();
   PINS_DRV_ClearPins(PTD,0x00000020);
}

according to the clock configuration,the expected running time of test program is 1us,but the measured running time is 4us,and I check the running mode of MCU S32K144,the mode is RUN mode,and use  SPLL_CLK as main clock.I don't understand why,could you give me any advice?  

pastedImage_1.png

0 Kudos
2 Replies

1,137 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

my recommendation is - if you want to generate precise delays, use a timer module.

Software delays should be used rather for rough delays when it is not so important. The reason is that today's microcontrollers have a number of features which increases the performance like prefetch buffers or cache. Then there are flash wait states, other bus masters and priority on crossbar and so on. All these features affect the timing.

It was possible to use precise software delays on old microcontrollers like 8051 where the timing was strictly given. But this is not an option now.

Regards,

Lukas

0 Kudos

1,137 Views
asd046012
Contributor III

Hi

      I  didn't expected a precise delays,as we see from the clock configuration,the core clock is 64MHz,so the command "nop" MCU executed is 1/64ns,and so MCU executed command "nop" 64 times,the time shall be 1us,but now I tested the time is 4us,the measured result is too different from the expected value.so I doubt the clock precision.

    Looking forward to your answer!!!

     Regards,

0 Kudos