2015-05-12 07:18 AM
Hi, I'm struggling with this on stm32f429 discovery board with arm cortex M4:
I have a reception task via UART which receive a character per time and put it in a circular buffer cbuff. When some conditions on the received character (i.e. \r has been received) and on the buffer (i.e. cbuff is full) this is printed over a terminal. For some reasons in the function which prints cbuff over the terminal I need to have a delay, so I call HAL_Delay(10). I also use freeRTOS and the calls cascade isreceptionTask()->HAL_UART_Receive_IT()->HAL_UART_RxCpltCallback()->cb_push_back()->HAL_Delay()
wherecb_push_back() is the function that manages cbuf. Withincb_push_back() I call HAL_Delay(10) and everything get stucked. Particularly, in turn HAL_Delay() calls HAL_GetTick() within the while loop (see stm32f4xx_hal.c for reference) and the latter never returns (uwTick is never increased I think).
Clearly, at least this is what I guess, it is matter of interrupts priorities. And here comes my troubles: according to freeRTOS.com and Google,SysTick priority must be the lowest possible (in my case 15) and my code fits this requirement. Further, according to UM1725 ''In the default implementation, SysTick timer is the source of
time base. It is used to generate interrupts at regular time
intervals. Care must be taken if HAL_Delay() is called from a
peripheral ISR process, The the SysTick interrupt must have
higher priority (numerically lower) than the peripheral
interrupt. Otherwise the caller ISR process will be blocked.
The function is declared as __weak to be overwritten in case
of other implementation in user file.''. So according to my particular case it looks like there is no way I can make it working since I can, at the best, have the UART Rx ISR priority equal to that of SysTick.
Am I right or am I missing something? Should I use timers instead?
Thank you and regards.
2015-05-12 07:45 AM
I need to have a delay
Identifying WHY you need one would be the first step. There are plenty of ways to insert a delay of known time without requiring an interrupt driven counter, or unnecessarily stalling an interrupt routine for 10's of milliseconds. See if you can use an existing free running counter.2015-05-18 09:03 AM
Imprudent things to do in an ISR - delay, execute a long time, call libraries.