FreeRTOS slower with an STM32F103RB

blackswords wrote on Friday, September 21, 2012:

Hi everybody,

I used FreeRTOS for a couple of projects based on an STM32F103VC and everything was working fine but now I switched to an STM32F103RB and for a reason that I ignore, the SysTick seems to run a about 100Hz instead of 1kHz… I measure this using the vApplicationTickHook().

I used the exactly same files for the different projects, I just changed some definitions (declare the MCU as a medium density for example).

I checked, the oscillator is set up to runs at 72MHz, as usual.

Do anyone has a lead on the origin of this behavior?


rtel wrote on Saturday, September 22, 2012:

It must be a chip configuration problem. 

The kernel uses the SysTick to generate tick interrupts.  SysTick is on the core itself and does not need clocking separately.  The calculation used to set the tick frequency itself uses configCPU_CLOCK_HZ and configTICK_RATE_HZ (both defined in FreeRTOSConfig.h).  If these settings are correct, but the tick frequency is wrong, it would indicate that the CPU is not running at the frequency you think it is.

I used the exactly same files for the different projects,

Does that include the same system files provided by ST?  If there is a setting in those files that is specific to the chip, then that might be the cause of the problem.  Nothing in the FreeRTOS files themselves will change between the chips.


blackswords wrote on Saturday, September 22, 2012:

Thanks for your answer.
No, not the same ST files. I changed the linker script and the startup file. The chip is declared as a medium density one.
In FreeRTOSConfig.h I have these lines :
#define configCPU_CLOCK_HZ ( 72000000UL )
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )

Is there any way to check the chip frequency?

blackswords wrote on Saturday, September 22, 2012:

I used a PWM output to check the frequency of the CPU and I have an output frequency of 11.11Hz instead of 100Hz.
So apparently the chip is running at 8MHz…
It’s not a FreeRTOS problem so we can close this thread but if someone has an idea to solve that…

rtel wrote on Saturday, September 22, 2012:

You could try finding the function that configures the CPU frequency, and then step into that using the debugger to see if there is a clue there (either in the comments, or a variable).  Be aware however that often a debugger will loose contact with the hardware if you try stepping over the instructions that change the CPU frequency (presumably because the JTAG frequency changes too).  The function that configures the clock might be called before main().

Alternatively, if you are using CMSIS libraries, you can try inspecting the SystemCoreClock variable.


blackswords wrote on Saturday, September 22, 2012:

Problem solved, I forgot that on this board I don’t have any external oscillator so I modified the clock configuration function to enable the PLL on the internal oscillator. I can reach 64MHz in this configuration.

Thanks for your help