Hi,I have some problems when developing on FreeRT OS.
Contidition:
MCU:STM32F103RE
OS:FreeRT OS V9.0.0(STM32CubeMX generate)
IDE: MDK5.26.2.0
Code condition:
1.All tasks are block task, should be actived by message(singal).
2.#define configLIBRARY
MAXSYSCALL
INTERRUPTPRIORITY 1 means all IT can be controlled by OS Kernel.
3.TIM4 interrupt priority is 5,and will send message(singal) in TIM4 ISR function.The TIM4 interrupt frequency is 1Hz.It means that send message(singal) in ISR frequency is 1Hz.
Q1:I do not know the reason code is crashing at list.c line 179 pxIterator = pxList->xListEnd.pxPrevious.
I have tested no stack overflow, a queue or semaphore has been initialised,
API function called by ISR end in “FromISR” (STM32CubeMX generate code,singal send function has been repackaged in case of sending singal in ISR error).
I am not sure that the interrupt priority settings is correct or not.
The bug that code is crashing at list.c line 179 pxIterator = pxList->xListEnd.pxPrevious is accidental.
Q2:If the message send twice with the same value(call send
msguserLcdMsgId(LCD
MSGID
S3) once in ISR,call sendmsg
userLcdMsgId(LCDMSG
IDS3) again before the task actived ),what the FreeRT OS kernel will do?
Best regards.
Task below:
~~~
/* UserLcdDisplayTask function
/
void UserLcdDisplayTask(void const * argument)
{
/ USER CODE BEGIN UserLcdDisplayTask
/
#ifdef DEBUG_BY_LUOGF
uint32_t recv;
osEvent evt;
#endif
DEBUG_BY_LUOGF_PRINTF(0,”>>>>[%4d][%s] is called.rn”,LINE,FUNCTION);
/ Infinite loop
/
for(;;)
{
#ifdef DEBUG_BY_LUOGF
evt = osMessageGet(userLcdMsgId,osWaitForever);
if(evt.status == osEventMessage)
{
recv = (evt.value.v);
DEBUG_BY_LUOGF_PRINTF(0,”>>[%d][%s][recv = %d] rn”,LINE,FUNCTION,recv);
switch(recv)
{
case LCD_MSG_ID_S1:
user_lcd_display();
break;
case LCD_MSG_ID_S2:
user_lcd_display();
break;
case LCD_MSG_ID_S3:
user_lcd_display();
case LCD_MSG_ID_S4:
user_lcd_display_rtc();
break;
default:
break;
}
set_user_lcd_display_flag(false);
}
#else
osDelay(1);
#endif
}
/ USER CODE END UserLcdDisplayTask */
}
~~~
Waiting for message to active task
~~~
evt = osMessageGet(userLcdMsgId,osWaitForever);//Waiting for Message
if(evt.status == osEventMessage)
{
recv = (evt.value.v);
DEBUG_BY_LUOGF_PRINTF(0,”>>[%d][%s][recv = %d] rn”,
LINE,
FUNCTION,recv);
switch(recv)
{
case LCD_MSG_ID_S1:
break;
case LCD_MSG_ID_S2:
user_lcd_display();
break;
case LCD_MSG_ID_S3:
user_lcd_display();
case LCD_MSG_ID_S4:
user_lcd_display_rtc();
break;
default:
break;
}
}
~~~
sending massage in ISR
~~~
void HAL_TIM_PeriodElapsedCallback_TIM4(TIM_HandleTypeDef *htim)
{
DEBUG_BY_LUOGF_PRINTF(0,”>>[%4d][%s]rn”,
LINE,
FUNCTION);
send_msg_userLcdMsgId(LCD_MSG_ID_S3);
DEBUG_BY_LUOGF_PRINTF(0,”<<[%4d][%s]rn”,
LINE,
FUNCTION);
}
~~~
send message function
~~~
void send_msg_userLcdMsgId(uint32_t id)
{
if(userLcdMsgId == NULL)
{
return;
}
else
{
if(get_user_lcd_display_flag() == false)
{
set_user_lcd_display_flag(true);
osStatus ret = osMessagePut(userLcdMsgId,(uint32_t)id,0);
DEBUG_BY_LUOGF_PRINTF(0,">>>>[%d][%s][id = 0x%x]rn",__LINE__,__FUNCTION__,id);
if(ret != osOK)
{
DEBUG_BY_LUOGF_PRINTF(0,">>>>[%d][%s][ret = 0x%x]rn",__LINE__,__FUNCTION__,ret);
}
}
}
}
~~~