STM32F103 with GCC systick err

labelsrbb wrote on Thursday, August 22, 2013:

Hi,
   I use FreeRTOS V7.5.2 on STM32F103RE with GCC compile. But systick seem to be wrong. When I use:
vTaskDelay(1000 / portTICK_RATE_MS), the delay time seem to be 10 second, not 1 second. xQueueReceive(g_VolCtrlQ, &stQItem,400 / portTICK_RATE_MS) also delay about 4 second, not 400ms.  But I run IAR Demo project is OK. Does any body meet this problem? Can anybody give me some advice? Thanks a lot.

rtel wrote on Thursday, August 22, 2013:

Are you using the same FreeRTOSConfig.h between the IAR and GCC projects? 

If so, how is configCPU_CLOCK_HZ being set?  If it is just mapped to SystemCoreClock then your GCC and IAR projects are probably setting SystemCoreClock differently, or the GCC project is not setting it at all.

If no, then is configCPU_CLOCK_HZ set to the same value in both files?

Are your IAR and GCC projects executing the same start up code?

It is likely the IAR project will be running start up code that configures the MCU clocks, and may even call a configuration file provided by the application before it calls main().  If you GCC project is not doing this then the frequency the chips are running at when main() is called could be different.

Regards.

mrichmond68 wrote on Thursday, December 11, 2014:

I’m also working with the STM32F103 and the GCC/ARM_CM3 port. Just wanted to add that as a newbie (which I am) it was not automatically clear how configCPU_CLOCK_HZ should be set and how much configuring I should do manually of sysTick before the freeRTOS got hold of it.

So here is what I found for V8.1.2, the GCC ARM_CM3 port. configCPU_CLOCK_HZ should be set to the core clock rate, not to the core clock/8, and I don’t need to do anything to SysTick. freeRTOS configures the SysTick clock source to be the core clock. This happens in FreeRTOS\Source\portable\GCC\ARM_CM3\port.c,vPortSetupTimerInterrupt().