STM32F10x tick rate 1/2 speed
Hello,
I am having difficulties with timers and vTaskDelay() with the STM32F processor. It appears that delays are about 2X the programmed rate.
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.
Sample code:
~~~~
TickTypet starttick;
TickTypet endtick;
do {
starttick = xTaskGetTickCount();
vTaskDelay(4000);
endtick = xTaskGetTickCount();
traceprintf(“msec2ticks:%u ticksn”, (uint16t)(endtick-starttick));
}
while (pdTRUE);
~~~~
Originally I thought this was a problem in 8.2.3, however I back ported to 8.2.0 and received the same results.
The only other change is the trace output configuration. Changed:
~~~~
STM32F10x tick rate 1/2 speed
Here is some more information:
- Created a BlinkyLED application from the Eclipse/GNUARM plugin. Removed all the LED related code and used the simple timer routines. These worked as expected.
- Copied the STM “system” code from the BlinkyLED project to the FreeRTOS test program. Same problem with the tick rate being 1/2 rate.
- Compared the RCC register configuration between the two programs. They were the SAME!
STM32F10x tick rate 1/2 speed
Hi Allen,
What is your program printing:
msec2ticks:4000 ticks
or
msec2ticks:8000 ticks
?
I suppose that configTICK_RATE_HZ
is defined as 1000
?
Wat does sysclk_get_cpu_hz()
return? Is the CPU really running at the expected frequency?
Regards.
STM32F10x tick rate 1/2 speed
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 configCPUCLOCKHZ is wrong. However, then you write:
#undef OS_USE_TRACE_SEMIHOSTING #define OS_USE_TRACE_ITMyou 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. Regards.
STM32F10x tick rate 1/2 speed
Hello,
Thank you for the reply. No, I am not using SEMIHOSTING. Originally I was but it was causing all sorts of problems.
My BSP does not have the sysclkgetclk_hz() function so I inserted the following code.
~~~~
trace_printf(“System clock: %u Hzn”, SystemCoreClock);
RCC_ClocksTypeDef clock;
RCC_GetClocksFreq(&clock);
trace_printf("SYSCLK=%ld,HCLK=%ld,PCLK1=%ld,PCLK2=%ld,ADCCLK=%ldn",
clock.SYSCLK_Frequency,
clock.HCLK_Frequency,
clock.PCLK1_Frequency,
clock.PCLK2_Frequency,
clock.ADCCLK_Frequency);
~~~~
This is the output
System clock: 8000000 Hz SYSCLK=8000000,HCLK=8000000,PCLK1=8000000,PCLK2=8000000,ADCCLK=4000000Based on this I debugged the SystemInit() function and determined that HSE never becomes ready. It looks like the oscillator isn’t working? Thank you for pointing me in the right direction.