当前采用28335型DSP开发了一个机器,定时器Timer0中有这么一段程序,U是一个已定义好的数组,400维。但是目前程序仅仅用了前200个点。
int temp1 = count;
int temp2 = countk;
int a = 0;
int b = 0;
int c = 0;
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;
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;
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;
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]);
机器便无法启动。启动过程中该段程序虽然运行,但是应该不会干扰到机器启动流程。