I am stuck with HAL_Delay() function. When i call this function HAL_Delay() , control stuck in infinite loop. While searching for the problem, I found this
http://www.openstm32.org/forumthread2145#threadId2146
In this particular comment which states and i quote "There is problem with linker file please use the one attached. You need to map two banks of memory separately so first SRAM1 96K and then SRAM2 of 32K. I think this should be reported as bug in CubeMX as it generates bad linker file." and there are two files with .ld extension.
What i am looking is how to use this files within my project OR any other better option for dealing with this problem.
PS. I am using stm32l476 discovery board, Cube Mx 5.0.0 and Attolic True Studio.
EDIT
My project is having an RS485 communication where from where i take data and i have two task with that data, display it on MAX7219 display and send it to internet using sim800 gsm module.
The code where the control is stuck. note that this function is only called when it is doing GSM tasks.
void vMyDelay(uint16_t ms)
{
HAL_UART_Transmit(&huart2, (uint8_t*)"\r\n", strlen("\r\n"), 1000);
HAL_UART_Transmit(&huart2, (uint8_t*)"In Delay", strlen("In Delay"), 1000);
HAL_UART_Transmit(&huart2, (uint8_t*)"\r\n", strlen("\r\n"), 1000);
for (int i = 0; i < ms; i++ ) HAL_Delay(1);
HAL_UART_Transmit(&huart2, (uint8_t*)"\r\n", strlen("\r\n"), 1000);
HAL_UART_Transmit(&huart2, (uint8_t*)"Out Delay", strlen("Out Delay"), 1000);
HAL_UART_Transmit(&huart2, (uint8_t*)"\r\n", strlen("\r\n"), 1000);
}
This function writes In Delay
on the terminal but Out Delay
is not displayed. But i am also having a timer which invokes every 2 sec to display the data on MAX72219.
The following code is
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
HAL_UART_Transmit(&huart2, (uint8_t*)"\r\n", strlen("\r\n"), 1000);
HAL_UART_Transmit(&huart2, (uint8_t*)"HAL_TIM_PeriodElapsedCallback()", strlen("vRS485_CollectInverterData()"), 1000);
HAL_UART_Transmit(&huart2, (uint8_t*)"\r\n", strlen("\r\n"), 1000);
if (htim->Instance == htim3.Instance)
{
vMax7219_ClearDisplay();
switch (uiMax7219Index)
{
case 0: vMax7219_SendNumberToString(ucFreq7219,1); break;
case 1: vMax7219_SendNumberToString(ucInVolt7219,1); break;
case 2: vMax7219_SendNumberToString(ucOutVolt7219,1); break;
case 3: vMax7219_SendNumberToString(ucOutCurr7219,1); break;
case 4: vMax7219_SendNumberToString(ucLoadSpd7219,1); break;
case 5: vMax7219_SendNumberToString(ucOutPwr7219,1); break;
}
uiMax7219Index++;
if (uiMax7219Index > 5) uiMax7219Index = 0;
}
}
After the control stuck, this function is always fires after 2 sec. An thus the conclusion that somehow the control is stuck in HAL_Delay()
.
IMP THING
the problem happens everytime but there is no specific time i.e the control might stuck after 5mins and 10 mins or 15mins. It doesnt stuck from a specific function. The functions might be different. i.e sometimes it might get stuck from function name getIMEI()
or sometime it might me get service provider
All delay and timeout HAL functions rely on a counter incremented in the SysTick
handler. If you are using any of these functions in another interrupt, you have to make sure that the SysTick
interrupt has a higher priority than that interrupt. Otherwise, the SysTick
handler is never called and you will end up in an infinite loop, as the counter will never be increased.