2
votes

I am experiencing a problem with FreeRTOS where it seems the systick() rate is 1/2 the expected rate. All timer or task delay functions take about 2X the time. This was verified in versions 8.2.0 and 8.2.3 using a STM32F100 processor.

There is another posting that looks very similar. This developer is using a MSP430 and claims the tick rate is 400Hz when expecting 1000Hz tick rate.

The RCC register configuration appears to be correct. If I create a non-FreeRTOS project where the systick is correct, it has the same RCC configuration as in the FreeRTOS version.

Suggestions?

1
Post your RCC configuration.LPs
Is the MCO pin (microcontroller clock output) available? If so you can configure this pin to output different internal clocks (e.g. SYSCLK) and measure the frequency at this pin using an oscilloscope to check if the clock is what you expect. If it is not, you either have the wrong external oscillator connected or you have the clocks wrongly configured.Habi
Ensure that configCPU_CLOCK_HZ and configTICK_RATE_HZ are set correctly in FreeRTOSConfig.h. Also review vPortSetupTimerInterrupt() in port.c to understand what it's doing.kkrambo
Just check whether you have configured the clocks correctly as everyone pointed outSamR

1 Answers

2
votes

When I read:

I created a very simple task that delays for 4 seconds and reports the actual number of elapsed ticks. The ticks are correct but the actually delay is around 8 seconds.

When reading this my thought was, if the delay is correct in the number of ticks, but the time is different, then this is simply a case of the CPU clock running at a different frequency to that which you think it is. Perhaps configCPU_CLOCK_HZ is wrong. However, then you write:

#undef OS_USE_TRACE_SEMIHOSTING
#define OS_USE_TRACE_ITM

you mention semihosting. Are you using semihosting? If so, don't, it will mess up your timing as it will stop the CPU while outputing to the host - and that might be the problem you are seeing.