在main中添加:

 

/**

 * @brief FreeRTOS 内存分配失败钩子函数

 */

void vApplicationMallocFailedHook(void)

{

    taskDISABLE_INTERRUPTS();

    printf("Malloc Failed Hook\r\n");

    for(;;);

}

 

/**

 * @brief FreeRTOS 栈溢出钩子函数

 */

void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName)

{

    (void) pxTask;

    printf("Stack Overflow Hook\r\n");

    for(;;);

}

 

在FreeRTOSConfig.h中添加

//add by mxx

#define configCHECK_FOR_STACK_OVERFLOW           1

#define configUSE_MALLOC_FAILED_HOOK             1

 

在回调函数中添加中断点,运行

freertos的钩子函数

程序奔溃,一直在

freertos的钩子函数

原因是内存不够用

freertos的钩子函数

 

 

由0x400改为0x800,

同时把configTOTAL_HEAP_SIZE变大

freertos的钩子函数

 

相关文章:

  • 2021-08-05
  • 2021-12-04
  • 2022-01-10
  • 2021-08-15
  • 2021-04-09
  • 2021-11-02
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-03-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
相关资源
相似解决方案