Questions about port.c function for Ti CCS compiler CM4F

Dear all
I am new to freeRTOS and trying some examples provided by TI with EK-TM4C1294XL LaunchPad , and noticed the function below - imported from …FreeRTOSv202212.01\FreeRTOS\Source\portable\CCS\ARM_CM4F, and have a few questions:

void xPortSysTickHandler( void )
{
    /* The SysTick runs at the lowest interrupt priority, so when this interrupt
     * executes all interrupts must be unmasked.  There is therefore no need to
     * save and then restore the interrupt mask value as its value is already
     * known. */
    ( void ) portSET_INTERRUPT_MASK_FROM_ISR();
    {
        /* Increment the RTOS tick. */
        if( xTaskIncrementTick() != pdFALSE )
        {
            /* A context switch is required.  Context switching is performed in
             * the PendSV interrupt.  Pend the PendSV interrupt. */
            portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
        }
    }
    portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );
}
  1. I cannot find the configuration of this sys tick rate, is it configured at 1ms interval? where I can find the code that configure the tick rate?
  2. In my old bare metal system, I use it for quite a few functions at lower tick rate like a few microSeconds, am I still be able to use it that way? in other words, am I allowed to modified it to run my own code?
  3. If no, is there a way that I can run some very fast routine regularly?

Thank you!
Ping

Hi @Ping

  1. You need to check the value of configTICK_RATE_HZ in FreeRTOSConfig.h of the project.
  2. Yes, you can set the tick rate as per the needs of your application . A higher “TICK_RATE_HZ” value means more frequent timer interrupts, which can be beneficial for applications that require very precise timing but can also increase CPU overhead due to the additional interrupt handling. A lower “TICK_RATE_HZ” value means less frequent timer interrupts, which can reduce CPU overhead but might not be suitable for applications that need precise timing.
  3. Most hardware are designed to handle timer interrupts within a reasonable range, typically between 1 and 1000 Hz.

Here - https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/portable/CCS/ARM_CM4F/port.c#L638.

You can modify the SysTick handler but if you want to run a fast routine, it would be better to use a different hardware timer available on your platform.

Hi, Rahul
Thanks for reply, I found the configure function with vPortSetupTimerInterrupt(), understand I am able to modify it with different tick rate, my question is:

  1. looks like xPortSysTickHandler() is used by OS as a time base.
  2. Am i allowed to add other function into it?
  3. Understand most system only needs 1 to 1000Hz, but in my old bare metal system, I need a some fast checking routine like doing I2C sending etc. and also check hardware changes, not sure how to do that.
    Regards!
    Ping

Look at General Purpose Timers chapter here - https://www.ti.com/lit/ds/symlink/tm4c1294ncpdt.pdf?ts=1737617359823&ref_url=https%253A%252F%252Fwww.mouser.in%252F.

Thank you for your suggestion.
Ping

Things like i2c transfers should be using the I2C device interrupts to move the transfer along. Once device I/O has been moved to be interrupt driven, most needs for very high speed timing goes away.