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?
dear Sir
It is not necessary to implement IRQ ,it is just done to be sure that time counter will be incremented without interruption,but I think resolution that this way I read the count value every switch context which give me result like this
Time count Task 0 7 0 3 0 2 1 4 1 3 1 5 3 2 3 1 4 4 4 7 7 5 7 4
something like that ,if the timer has more precision thant tick OS then why I have for two tasks the same counter value wich mean interruption doesnt occur between switch context ,right ? 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?
"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?