For some reason SysTick gets freezed in the USART_RxCpltCallback() even when systick priority is lower than USART priority, why?
Hi all, how are you?, I'm adapting some libraries for nextion HMI's to use with STM32F4 MCUs, then one of them uses the MCU timer which in my case is systick to determine if time has expired, the function is the following
/*
* Receive string data.
*
* @param buffer - save string data.
* @param len - string buffer length.
* @param timeout - set timeout time.
*
* @return the length of string buffer.
*
*/
uint16_t recvRetString(char *buffer, uint32_t len, uint32_t timeout)
{
uint16_t ret = 0;
_Bool str_start_flag = false;
uint8_t cnt_0xff = 0;
char temp[30] = {0};
uint8_t c = 0;
long start;
uint8_t indice = 0;
if(!buffer || len == 0)
{
sprintf(temp, "RecvRetString[%d, %s]\r\n", strlen(temp), temp);
dbSerialPrint((uint8_t *) temp);
return c;
}
start = HAL_GetTick();
while((HAL_GetTick() - start) <= timeout)
{
while(indice < len)
{
c = buffer[indice];
if(str_start_flag)
{
if(0xff == c)
{
cnt_0xff++;
if(cnt_0xff >= 3)
{
break;
}
}
else
{
temp[c] = (char) c;
}
}
else if(NEX_RET_STRING_HEAD == c)
{
str_start_flag = true;
}
indice++;
}
if(cnt_0xff >= 3)
{
break;
}
}
ret = strlen(temp);
ret = ret > len ? len : ret;
strncpy(buffer, temp, ret);
sprintf((char *) temp, "RecvRetString[%d, %s]\r\n", strlen(temp), temp);
dbSerialPrint((uint8_t *) temp);
return ret;
}now, I want to use that function which breaks down the content of a buffer and after that it prints it over the debug port, the problem here is that I'm calling the above function inside the HAL_UART_RxCpltCallback(...), when I use that function inside the callback then systick freezes and I think this shouldn't be happening because systick priority is -1 and USART priority is 37. In fact systick should be able to preempt the USART priority.
The priority group is configured for priority group 4 as you can see in the following code
HAL_StatusTypeDef HAL_Init(void)
{
/* Configure Flash prefetch, Instruction cache, Data cache */
#if (INSTRUCTION_CACHE_ENABLE != 0U)
__HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
#endif /* INSTRUCTION_CACHE_ENABLE */
#if (DATA_CACHE_ENABLE != 0U)
__HAL_FLASH_DATA_CACHE_ENABLE();
#endif /* DATA_CACHE_ENABLE */
#if (PREFETCH_ENABLE != 0U)
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
#endif /* PREFETCH_ENABLE */
/* Set Interrupt Group Priority */
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
/* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
HAL_InitTick(TICK_INT_PRIORITY);
/* Init the low level hardware */
HAL_MspInit();
/* Return function status */
return HAL_OK;
}so I don't know whats happening or to be more clear, what I'm doing wrong?.
Thanks in advance for all the help.
