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

全局变量未赋值,但是发生了变化,是什么问题?

CC2640, simple_peripheral_oad_offchip, simplelink_cc2640r2_sdk_1_50_00_58

有一个全局变量,程序上没有对其进行加减和赋值,但是它的值一直在变化,请问是什么问题呢?内存溢出?

Viki Shi:

可否明示是哪个变量?

one Man:

回复 Viki Shi:

uint8_tSystem_Input_Key_Index = 0;//第几次按下的

一个自定义变量

one Man:

回复 one Man:

Alvin Chen:

回复 one Man:

你把你debug的图贴出来看看,以及code

Viki Shi:

回复 one Man:

最有可能的确实是内存,内存问题比较难定位。如果有做版本管理的话,可以直接对比下

one Man:

回复 Alvin Chen:

以上是两张不同时间的Debug状态图;

以上是System_Input_Key_Index出现的地方,并没有加减,只有赋值0,但是System_Input_Key_Index却会变为非0值。

Alvin Chen:

回复 one Man:

很奇怪在你gt316I.h 添加了声明 extern uint8_t System_Input_Key_Index; ? 但是应该没有影响,debug赋值为0,那一步时候没有赋值正确吗?

one Man:

回复 Alvin Chen:

是的,gt316l.h中有声明extern uint8_tSystem_Input_Key_Index;
赋值正确的。

Alvin Chen:

回复 one Man:

能否debug 看一下在哪一步发生的变化?

one Man:

回复 Alvin Chen:

void Input_Key_Fun_Process_EmptyArray()
{System_Input_Key_Index = 0;memset(System_PassWord_Array, KEY_NULL, INPUTKEYMAXCOUNT);
}
执行完Input_Key_Fun_Process_EmptyArray()这个函数后跳至Misc_Loop(), System_Input_Key_Index就发生变化了,Misc_Loop()在一个任务的for循环里面。

for(;;)
{
//Task handle…
Misc_Loop();
}

赞(0)
未经允许不得转载:TI中文支持网 » 全局变量未赋值,但是发生了变化,是什么问题?
分享到: 更多 (0)