如何在 Arduino 中转储我的堆栈? [英] How do I dump my stack in Arduino?

查看:26
本文介绍了如何在 Arduino 中转储我的堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来转储我的 arduino 堆栈.我知道有一个可用的堆栈指针 (SP),我现在尝试的是:

I'm looking for a way to dump the stack of my arduino. I know there is a stack pointer (SP) available, what I try at the moment is:

char* stack = (char*)SP;
int counter = 0;
strncpy(c, &stack[counter], 1);
while(counter < 200)
{
  counter++;
  strncat(c, &stack[counter], 1);
}
Serial.print(c);   

我没有得到像堆栈这样的东西,所以我不知道我是否做得对.请帮忙!

I don't get anything like a stack so I don't know if I'm doing it right. Please help!

推荐答案

uint8_t stackArray[30];
void createStackDump() 
{
  volatile uint8_t* mSP = (uint8_t*)SP;

  for (int i = 0; i < 30; i++) 
  {
    stackArray[i] = *mSP;
    mSP++;
  }
}

这篇关于如何在 Arduino 中转储我的堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆