We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Dear Sir
I have a freertos running on the stm32 microncontroller(stm32f101VD),I use a trace function from the API of freertos to record ticks and corresponding tasks
Now the problem is that the tick resolution is too high for me and this means that for the same tick I have manay task recorde, and this because a switch contest can occur betwenn two tick freertos.
So I tried to implement a timer and use the count value in in this trace function API from freertos.
I proceeded like that (from the example code you give ):
void TIM2_Init (void) { RCC->APB2ENR |= RCC_APB1ENR_TIM2EN; /* enable clock for TIM4 */ TIM2->PSC = ( 1 - 1); /* set prescaler = 10KHz */ TIM2->ARR = 0xFFFF; /* set auto-reload = 250 ms */ TIM2->RCR = 0; /* set repetition counter */ TIM2->DIER = TIM_DIER_UIE; /* Update Interrupt enable */ NVIC_EnableIRQ(TIM2_IRQn); /* TIM2 Interrupt enable */ TIM2->CR1 |= TIM_CR1_CEN; /* timer enable */ } void TIM2_IRQHandler (void) { trace_counter++; // this variable change value actually but cant have the count more //precise ,have same problem as before if (TIM2->SR & (TIM_SR_UIF)) { /* UIF set? */ TIM2->SR &= ~(TIM_SR_UIF); /* clear UIF flag */ }
Can you please tell me how can I implement this counter?
"So how to impelement a precise timer that will really be more precise than switch context?and this way allow recording tasks in real time?"
Did you consider what I wrote, and checked if the timers in your specific processor have the required capabilities to implement the variant I suggested?