硬汉嵌入式论坛

 找回密码
 立即注册
查看: 3868|回复: 6
收起左侧

[有问必答] 在freertos例子中检测堆栈溢出的两种方法

[复制链接]

96

主题

297

回帖

585

积分

金牌会员

123

积分
585
发表于 2018-8-29 08:58:27 | 显示全部楼层 |阅读模式
在freertos例子中检测堆栈溢出的两种方法,没找到钩子函数在哪里调用了
  1. void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )
  2. {
  3.         printf("任务:%s堆栈溢出\r\n", pcTaskName);
  4. }
复制代码

  1. /*-----------------------------------------------------------*/

  2. __asm void xPortPendSVHandler( void )
  3. {
  4.         extern uxCriticalNesting;
  5.         extern pxCurrentTCB;
  6.         extern vTaskSwitchContext;

  7.         PRESERVE8

  8.         mrs r0, psp
  9.         isb

  10.         ldr        r3, =pxCurrentTCB                /* Get the location of the current TCB. */
  11.         ldr        r2, [r3]

  12.         stmdb r0!, {r4-r11}                        /* Save the remaining registers. */
  13.         str r0, [r2]                                /* Save the new top of stack into the first member of the TCB. */

  14.         stmdb sp!, {r3, r14}
  15.         mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
  16.         msr basepri, r0
  17.         bl vTaskSwitchContext
  18.         mov r0, #0
  19.         msr basepri, r0
  20.         ldmia sp!, {r3, r14}

  21.         ldr r1, [r3]
  22.         ldr r0, [r1]                                /* The first item in pxCurrentTCB is the task top of stack. */
  23.         ldmia r0!, {r4-r11}                        /* Pop the registers and the critical nesting count. */
  24.         msr psp, r0
  25.         isb
  26.         bx r14
  27.         nop
  28. }
  29. /*-----------------------------------------------------------*/

  30. void xPortSysTickHandler( void )
  31. {
  32.         /* The SysTick runs at the lowest interrupt priority, so when this interrupt
  33.         executes all interrupts must be unmasked.  There is therefore no need to
  34.         save and then restore the interrupt mask value as its value is already
  35.         known. */
  36.         ( void ) portSET_INTERRUPT_MASK_FROM_ISR();
  37.         {
  38.                 /* Increment the RTOS tick. */
  39.                 if( xTaskIncrementTick() != pdFALSE )
  40.                 {
  41.                         /* A context switch is required.  Context switching is performed in
  42.                         the PendSV interrupt.  Pend the PendSV interrupt. */
  43.                         portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
  44.                 }
  45.         }
  46.         portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );
  47. }
  48. /*-----------------------------------------------------------*/
复制代码


rrt.png
回复

使用道具 举报

28

主题

274

回帖

358

积分

高级会员

积分
358
发表于 2018-8-29 10:09:50 | 显示全部楼层
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106989
QQ
发表于 2018-8-29 14:20:08 | 显示全部楼层
QQ截图20180829141730.png
回复

使用道具 举报

96

主题

297

回帖

585

积分

金牌会员

123

积分
585
 楼主| 发表于 2018-8-29 14:26:19 | 显示全部楼层
本帖最后由 ssssssss 于 2018-8-29 14:32 编辑

同样的方法,我这里没搜到(刚搜到了,不知道为什么早上没搜出来),顺便问一下,

1.您的bsp驱动包最新版在哪里下?
2.好像v5的用户手册只是讲到串口fifo,提高篇后面的没有了,想学模拟定时器这块,
3.v6板子的用户手册我没找到

回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106989
QQ
发表于 2018-8-29 14:49:21 | 显示全部楼层
ssssssss 发表于 2018-8-29 14:26
同样的方法,我这里没搜到(刚搜到了,不知道为什么早上没搜出来),顺便问一下,

1.您的bsp驱动包最 ...

全编译后搜索。

1、网盘里面出厂程序带的。
2、模拟定时器是说的bsp_timer.c文件里面的软件定时器吗
3、V6的有些资料没有开源出来,看V5的就行,用户手册基本差不多
回复

使用道具 举报

96

主题

297

回帖

585

积分

金牌会员

123

积分
585
 楼主| 发表于 2018-8-29 15:03:51 | 显示全部楼层
本帖最后由 ssssssss 于 2018-8-29 15:04 编辑
eric2013 发表于 2018-8-29 14:49
全编译后搜索。

1、网盘里面出厂程序带的。

1.刚下载了V4的出厂程序,不知道是不是最新的?
2.是啊,软件定时器在写一个小系统的时候很有用,好像用户手册只是到串口fifo就停了,是还没更新吗
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106989
QQ
发表于 2018-8-30 00:37:11 | 显示全部楼层
ssssssss 发表于 2018-8-29 15:03
1.刚下载了V4的出厂程序,不知道是不是最新的?
2.是啊,软件定时器在写一个小系统的时候很有用,好像用 ...

1、论坛置顶帖里面就是最新的了。
2、对,软件定时器的好理解,函数不多,你可以先看看,有问题随时交流。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-13 09:33 , Processed in 0.288910 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表