More CTL ticks per second
Hi,
My STM32 applications are mostly CTL-based. I am having problems with UARTs needing very large buffers (populated by UART ISRs) before my tasks get round to pulling out the data. If possible I would like to have my task consume waiting UART data more speedily rather than at most every CTL 1ms if there was no data waiting on the last check. Looking at the code in STM32F10x_ctl.c, I wonder if in fact the minimum time between checks is 10ms. Is there a flag somewhere I can modify to ramp up CTL (driven from SysTick?) or what should a "hack" look like? Is this recommended?
An alternative might be to have a task suspend and then resumed when the UART receive buffer reached a certain level or on timeout. Once resumed it could lock out other tasks, consume all UART data, release other tasks and then re-suspend. Am I right in thinking that I cannot make CTL calls from within an ISR?
Thanks for your help.
Jolyon
-
check out the ctl_start_timer() in STM32_ctl.c
the bit of interest is and yes, default is 10ms
SysTick->LOAD = (SystemCoreClock/8/100)-1; // interrupt every 10 ms
#ifdef CTL_TASKING
ctl_time_increment = 10; // so increment the counter by 10 to get the ms counter
#endifchange to
SysTick->LOAD = (SystemCoreClock/8/1000)-1; // interrupt every 1 ms
ctl_time_increment = 1;
-
You can make CTL calls from within an ISR. But you must use the ctl_enter_isr() and ctl_exit_isr() calls so that the system can know to check for a context-switch when leaving the outermost ISR:
void ADC3_IRQHandler(void) {
ctl_enter_isr();
ctl_events_set_clear(&adc_es, ADC_ES_CONVERSION, 0);
ADC3->SR = ~ADC_SR_EOC; // on return the previously-waiting thread will execute immediately
} -
Hi,
I'm trapped with the same problem - I need to do a calculation every 1 ms but the ctl_time_increment is set to 10.
I changed the counter load from TEN_MS to ONE_MS as indicated below (slightly different from the example above - hence I paste the entire function.)
I also tried defining CTL_TASKING in the preprocessor declarations but nether changed the ctl_time_increment from 10 to 1. And I checked in real time as well so there really still is a 10ms resolution on the timer.
Any additional help is appreciated.
void ctl_start_timer(CTL_ISR_FN_t timerFn)
{
userTimerISR = timerFn;
// SysTick->LOAD = TEN_MS-1;
SysTick->LOAD = ONE_MS-1;
SysTick->VAL = 0;
#ifdef USEPROCESSORCLOCK
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk;
#else
SysTick->CTRL = SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk;
#endif
#ifdef CTL_TASKING
// Set PendSV priority (PendSV must have lowest priority)
ctl_set_priority(PendSV_IRQn, ctl_lowest_isr_priority());
#endif
// Set SysTick priority
ctl_set_priority(SysTick_IRQn, ctl_highest_isr_priority());
}
Please sign in to leave a comment.
Comments
7 comments