2014-09-18 04:24 AM
Hello community,
first of all I’m using the STM32F103RCT6, CooCox IDE 1.7.7 and ARM GCC 4.8.
Now to my problem.
I’m trying to implement a task similar processing by using the Systick timer.
I initialized the SysTick timer as follows:
uint32_t returnCode =
SysTick_Config
(8000);if
(returnCode != 0) {
//
TODO
Error handling
}
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
The System clock is set to PLL 64MHz. The AHB clock is also set to 64MHz.
I expect that every millisecond an interrupt is being triggered.
t=(8/64MHz)*8000 = 1ms.
Within the interrupt handler a timer value will be increased. volatile uint32_t timeMS = 0;void
SysTick_Handler(
void
) {
timeMS++;
}
Using the following function I’m trying to generate a task every 3 seconds. More accurately the inner function will be called every 3 seconds. The printf() function writes the values of the global and internal timers to the UART interface.
void
task1_handler(uint32_t timer){
static
uint32_t internalTimerCount = 0;
if
(timer >= (internalTimerCount + 3000)) {
printf(
''Task1: GlobalTimer %d, IntTimer %d \r\n''
,timer, internalTimerCount);
internalTimerCount = timer;
}
}
If i’m using this task_handler the inner function will be called every 6 seconds instead of expected 3 seconds.
I
don’t know
exactly where
the
error is or what I did wrong.
I
hope you
can help
me.
This issue is driving me crazy.
Many thanksAlex
2014-09-18 05:10 AM
if (SysTick_Config(SystemCoreClock / 1000))
{ /* Capture error */ while (1); } Not sure how your SysTick interrupt, timeMS, interact with your other task and it's flow.