TI中文支持网
TI专业的中文技术问题搜集分享网站

在线等,急!~求驻大神,中断中调用数组,运行不正常。

当前采用28335型DSP开发了一个机器,定时器Timer0中有这么一段程序,U是一个已定义好的数组,400维。但是目前程序仅仅用了前200个点。
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;
 a = temp1 – 100 + 1;
 if (a < 0)
  a += 200;
 b = temp1 – 100;
 if (b < 0)
  b += 200;
 c = temp1 – 100 – 1;
 if (c < 0)
  c += 200;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

同样的程序,仅修改为
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;

 a = temp1 – 200 + 1;
 if (a < 0)
  a += 400;
 b = temp1 – 200;
 if (b < 0)
  b += 400;
 c = temp1 – 200 – 1;
 if (c < 0)
  c += 400;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

机器便无法启动。启动过程中该段程序虽然运行,但是应该不会干扰到机器启动流程。

Green Deng:你好,看程序没看出来有什么问题。使用的具体是哪个例程?出错点在哪里,可以用单步运行测试一下?count和countk可能的值是多少?

当前采用28335型DSP开发了一个机器,定时器Timer0中有这么一段程序,U是一个已定义好的数组,400维。但是目前程序仅仅用了前200个点。
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;
 a = temp1 – 100 + 1;
 if (a < 0)
  a += 200;
 b = temp1 – 100;
 if (b < 0)
  b += 200;
 c = temp1 – 100 – 1;
 if (c < 0)
  c += 200;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

同样的程序,仅修改为
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;

 a = temp1 – 200 + 1;
 if (a < 0)
  a += 400;
 b = temp1 – 200;
 if (b < 0)
  b += 400;
 c = temp1 – 200 – 1;
 if (c < 0)
  c += 400;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

机器便无法启动。启动过程中该段程序虽然运行,但是应该不会干扰到机器启动流程。

兵家墨梅:

回复 Green Deng:

count然后会累加,count值最大199,countk最大也为199。程序块以通过仿真验证过,count和countk不会超过数组边界,单步运行也没啥问题。

当前采用28335型DSP开发了一个机器,定时器Timer0中有这么一段程序,U是一个已定义好的数组,400维。但是目前程序仅仅用了前200个点。
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;
 a = temp1 – 100 + 1;
 if (a < 0)
  a += 200;
 b = temp1 – 100;
 if (b < 0)
  b += 200;
 c = temp1 – 100 – 1;
 if (c < 0)
  c += 200;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

同样的程序,仅修改为
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;

 a = temp1 – 200 + 1;
 if (a < 0)
  a += 400;
 b = temp1 – 200;
 if (b < 0)
  b += 400;
 c = temp1 – 200 – 1;
 if (c < 0)
  c += 400;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

机器便无法启动。启动过程中该段程序虽然运行,但是应该不会干扰到机器启动流程。

兵家墨梅:

回复 Green Deng:

另外,结构体分配内存的时候,也有一些疑惑,
U数组设置为200的时候,map中相关变量地址如下:
Re_A为包含U数组的结构体变量,内含有除去U外9个float型变量,U设为200时,共计209,Re_A、Re_C、Re_B为相同结构体变量
addressdatapagename
0000bc802f2 (0000bc80)_Re_A
0000be402f9 (0000be40)_Re_C
0000c000300 (0000c000)_Re_B
bc80-be40=1c0(448)
float变量个数为:448/4=112
为啥不是209?或212(4的整数倍)
仅改变U数组的维数,维数设置为400
0000cb8032e (0000cb80)_Re_CurrentA
0000cec033b (0000cec0)_Re_CurrentC
0000d200348 (0000d200)_Re_CurrentB
仅改变U数组的维数,维数设置为600
0000cb8032e (0000cb80)_Re_CurrentA
0000d080342 (0000d080)_Re_CurrentC
0000d580356 (0000d580)_Re_CurrentB

当前采用28335型DSP开发了一个机器,定时器Timer0中有这么一段程序,U是一个已定义好的数组,400维。但是目前程序仅仅用了前200个点。
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;
 a = temp1 – 100 + 1;
 if (a < 0)
  a += 200;
 b = temp1 – 100;
 if (b < 0)
  b += 200;
 c = temp1 – 100 – 1;
 if (c < 0)
  c += 200;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

同样的程序,仅修改为
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;

 a = temp1 – 200 + 1;
 if (a < 0)
  a += 400;
 b = temp1 – 200;
 if (b < 0)
  b += 400;
 c = temp1 – 200 – 1;
 if (c < 0)
  c += 400;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

机器便无法启动。启动过程中该段程序虽然运行,但是应该不会干扰到机器启动流程。

Green Deng:

回复 兵家墨梅:

抱歉暂时无法解决你的问题,我将问题发送到了英文E2E论坛了,你可以跟帖咨询一下:
e2e.ti.com/…/2958313

当前采用28335型DSP开发了一个机器,定时器Timer0中有这么一段程序,U是一个已定义好的数组,400维。但是目前程序仅仅用了前200个点。
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;
 a = temp1 – 100 + 1;
 if (a < 0)
  a += 200;
 b = temp1 – 100;
 if (b < 0)
  b += 200;
 c = temp1 – 100 – 1;
 if (c < 0)
  c += 200;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

同样的程序,仅修改为
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;

 a = temp1 – 200 + 1;
 if (a < 0)
  a += 400;
 b = temp1 – 200;
 if (b < 0)
  b += 400;
 c = temp1 – 200 – 1;
 if (c < 0)
  c += 400;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

机器便无法启动。启动过程中该段程序虽然运行,但是应该不会干扰到机器启动流程。

兵家墨梅:

回复 Green Deng:

太感谢了,亲

当前采用28335型DSP开发了一个机器,定时器Timer0中有这么一段程序,U是一个已定义好的数组,400维。但是目前程序仅仅用了前200个点。
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;
 a = temp1 – 100 + 1;
 if (a < 0)
  a += 200;
 b = temp1 – 100;
 if (b < 0)
  b += 200;
 c = temp1 – 100 – 1;
 if (c < 0)
  c += 200;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

同样的程序,仅修改为
int temp1 = count;
 int temp2 = countk;
 int a = 0;
 int b = 0;
 int c = 0;

 a = temp1 – 200 + 1;
 if (a < 0)
  a += 400;
 b = temp1 – 200;
 if (b < 0)
  b += 400;
 c = temp1 – 200 – 1;
 if (c < 0)
  c += 400;
 U[temp1] = 0.25 * (U[a] + 2 * U[b] + U[c]);

机器便无法启动。启动过程中该段程序虽然运行,但是应该不会干扰到机器启动流程。

Green Deng:

回复 兵家墨梅:

你客气了,很遗憾没能帮你解决问题。祝你后期调试顺利

赞(0)
未经允许不得转载:TI中文支持网 » 在线等,急!~求驻大神,中断中调用数组,运行不正常。
分享到: 更多 (0)