Hi, I have an application running on an LPC4357 (MBC4300) using the latest uVision etc CMSIS drivers etc. I want to get the system tick to operate at 100us rather than the default 1ms (for faster serial comms task reaction). When I adjust it down to 100us it has no effect even the LED stays the same time, increasing it works but decreasing it does not or does strange things e.g. 750 brings it up to 1.5ms? The system and thread viewer shows 0.100msec (when set to 100us). Adjusting the System Tick Timer down manually works (it it was set to 1000 in the first place). Its as if the RTOS is adjusting it in some way never allowing less than 1ms. Does anyone have any ideas? Thanks
Its the CMSIS RTOS using Keil RTX.
Its the delays that we want better granularity on. Below is all I could finds from the manuals. There are recommendations of 1ms but I can't find anything saying you can't go lower. The RTX_Config_CM.c wizard doesn't have any limitations.
I get the impression that if you lower the tick interval the RTOS trys to adjust the delays (sometimes erroneously) to be 1ms. "The CMSIS-RTOS RTX functions provide delays in units of milliseconds that are DERIVED from the RTX Timer Tick." This would make sense if it wasn't for fact that increasing the value to 2000 give me delays of 2ms?
From the RTX manual......
The RTX kernel for ARM7™ and ARM9™ uses one of the standard ARM timers to generate a periodic interrupt. RTX kernel for Cortex™-M uses common SysTick timer. This interrupt is called the RTX kernel timer tick. For some of the RTX library functions, you must specify timeouts and delay intervals in number of RTX kernel timer ticks.
The parameters for the RTX kernel timer are selected in the RTX_Config.c configuration file. Each ARM microcontroller family provides a different peripherals that are supported with different RTX_Config.c files.
For example, the RTX_Config.c file for NXP LPC2100/LPC2200 allows to use Timer 0 or Timer 1 for the RTX kernel timer.
The timer clock value specifies the input clock frequency and depends on CPU clock and APB clock. For a device with CPU clock 60 MHz and VPB divider 4 the peripheral clock is 15MHz and therefore the value is set to 15000000.
The time tick value specifies the interval of the periodic RTX interrupt. The value 10000 us configures timer tick period of 0.01 seconds.
This is from the CMSIS manual.....
The System Tick Time (SysTick) generates interrupt requests on a regular basis. This allows an OS to carry out context switching to support multiple tasking. For applications that do not require an OS, the SysTick can be used for time keeping, time measurement, or as an interrupt source for tasks that need to be executed regularly.
From the MDK_ARM primer (google search)......
The System Tick Timer (SYSTICK Timer) is a simple 24-bit down counter. The timer can be started and configured with an automatic reload value. If the timer is running and it's IRQ is enabled, it generates periodic interrupts. The System Tick Timer can use the internal clock (FCLK, the free running clock signal on the Cortex-M processor) or the external clock (the STCLK signal on the Cortex-M processor). The System Tick Timer is often used by the RTOS.
From the RTX Kernel Tick Timer Configuration.....
The CMSIS-RTOS RTX functions provide delays in units of milliseconds that are derived from the RTX Timer Tick. It is therefore recommended to configure the RTX Timer Tick to generate a 1 millisecond interval. Configuring a longer RTX Timer Tick may reduce energy consumption, but has impacts on the granularity of the timeouts.
The value #define OS_CLOCK specifies the Cortex-M processor clock frequency in Hz. This value is used to calculate the RTX kernel timer reload value.
The value #define OS_TICK specifies the RTX Timer Tick interval in microseconds (us). This value is used to calculate timeout values. When the SysTick core timer is enabled the value is also used to configure the SysTick timer. It is recommended to configure the RTX Timer tick to 1000 us which results in a timeout granularity of 1 millisecond
Hi Ian,
You might have already figured this out considering how long ago this thread was started.
We had similar issues with the Systick Timer. It is unfortunately not documented anywhere but we were able to get better granularity by calling
SysTick_Config (SystemCoreClock / 10000); //100us granularity
Regards, Jonathan