wenbo2005.online

学习记录 / FreeRTOS

RAM 溢出检测

FreeRTOS2024-07-11

1,对于128字的默认任务:

            osDelay(5000);
        printf("Send\r\n");
        uint32_t qwe[128] = {0};
        HAL_GPIO_TogglePin(GPIOC,LED0_Pin);

该程序,只能发送一次,LED翻转一次,因为第二次RAM溢出严重,系统已经卡死;但qwe[110]时,溢出不是很严重,会进入一次溢出检测程序(需要开启);

2,开启溢出检测:

Config->CHECK_FOR_STACK_OVERFLOW->选择Option2(全面检测,慢),Option1(检测快,但只是局部检测)

3,app_freertos.c中:

__weak void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName)
{
   /* Run time stack overflow checking is performed if
   configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
   called if a stack overflow is detected. */
    printf("RAM  many!!\r\n");                                        //在溢出不是严重时,会打印一次
}