IMXRT1170 SysTick Clock Root not Working as Expected

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

IMXRT1170 SysTick Clock Root not Working as Expected

Jump to solution
929 Views
zylalx1
Contributor II

According to the IMXRT1170 Reference Manual, there are two clock roots for the M7 core (ROOT0 for core and ROOT8 for systick) and two clock roots for the M4 core (ROOT1 for core and ROOT7 for systick). So I assume changing the ROOT8 and ROOT7 frequency affects the systick timer counting interval. 

But in a simple test on an EVK1176 board I found the systick timer counting interval actually only depends on the ROOT0 and ROOT1 frequency. Seems like the ROOT8 and ROOT7 have nothing to do with the systick at all. 

 

uint32_t count=0;

void SysTick_Handler(){
    count++;
    if(count>=100000){
        count=0;
        GPIO_PortToggle(EXAMPLE_LED_GPIO, 1u << EXAMPLE_LED_GPIO_PIN);
    }
}

int main(void)
{
    gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};

    BOARD_ConfigMPU();
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();


    clock_root_config_t rootCfg = {0};

    //It says CLOCK_ROOT0 (Core M7 core clock root)
    //But systick interval actually depends on this clock frequency. Strange?
    rootCfg.mux = kCLOCK_M7_ClockRoot_MuxArmPllOut;
    rootCfg.div = 2;
    //rootCfg.div = 1;
    CLOCK_SetRootClock(kCLOCK_Root_M7, &rootCfg);

    //It says CLOCK_ROOT8 (Core M7 systick clock root)
    //But changing this clock frequency has no effect on systick interval. Strange?
    rootCfg.mux = kCLOCK_M7_SYSTICK_ClockRoot_MuxOsc24MOut;
    rootCfg.div = 24;
    //rootCfg.div = 240;
    CLOCK_SetRootClock(kCLOCK_Root_M7_Systick, &rootCfg);


    GPIO_PinInit(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, &led_config);

    SysTick_Config(10000);

    while (1)
    {

    }
}

 

In this example, changing the ROOT0 .div value affects the LED blinking speed while changing the ROOT8 .div value does not. This example is for the M7 core but I also tested the M4 core and got the same result. 

Did I miss something or it is a bug? 

Labels (1)
0 Kudos
Reply
1 Solution
874 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @zylalx1,

I believe the issue you are experiencing is due to the SysTick configuration. On the BOARD_BootClockRUN() function, the SysTick_CTRL_CLKSOURCE_Msk is set, which means that you set up the SysTick timer to use the processor's clock, as seen ARM's documentation here: https://developer.arm.com/documentation/ddi0403/d/System-Level-Architecture/System-Address-Map/The-s...

This is why any changes on CLOCK_ROOT8 seem to be ignored, while changes on CLOCK_ROOT0 do affect the timer. Disable the CLKSOURCE bit and the clock configurations for the SysTick will follow the routes mentioned by my colleague on the following post: https://community.nxp.com/t5/i-MX-RT/i-MX-RT-1170-Systick-internal-external-source-CLKSOURCE/td-p/13...

BR,
Edwin.

View solution in original post

0 Kudos
Reply
1 Reply
875 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @zylalx1,

I believe the issue you are experiencing is due to the SysTick configuration. On the BOARD_BootClockRUN() function, the SysTick_CTRL_CLKSOURCE_Msk is set, which means that you set up the SysTick timer to use the processor's clock, as seen ARM's documentation here: https://developer.arm.com/documentation/ddi0403/d/System-Level-Architecture/System-Address-Map/The-s...

This is why any changes on CLOCK_ROOT8 seem to be ignored, while changes on CLOCK_ROOT0 do affect the timer. Disable the CLKSOURCE bit and the clock configurations for the SysTick will follow the routes mentioned by my colleague on the following post: https://community.nxp.com/t5/i-MX-RT/i-MX-RT-1170-Systick-internal-external-source-CLKSOURCE/td-p/13...

BR,
Edwin.

0 Kudos
Reply