|
大哥,我遇到不正常情况了
void ExtraCode_StateMachine(void)
{
if ((TSL_GlobalSetting.b.CHANGED) && (TSLState == TSL_IDLE_STATE))
{
TSL_GlobalSetting.b.CHANGED = 0;
if (sSCKeyInfo[0].Setting.b.DETECTED) /* KEY 1 touched */
{
if (Led1State == OFF)
{
LED1_ON();
}
else
{
LED1_OFF();
}
UART2_DR = key1;
while (!(UART2_SR & 0x80));
}
if (sSCKeyInfo[1].Setting.b.DETECTED) /* KEY 2 touched */
{
if (Led2State == OFF)
{
LED2_ON();
}
else
{
LED2_OFF();
}
while (sSCKeyInfo[1].Setting.b.DETECTED == 1)
{
UART2_DR = key2;
while (!(UART2_SR & 0x80));
}
}
if (sSCKeyInfo[2].Setting.b.DETECTED) /* KEY 3 touched */
{
if (Led3State == OFF)
{
LED3_ON();
}
else
{
LED3_OFF();
}
UART2_DR = key3;
while (!(UART2_SR & 0x80));
}
}
}
我的程序是上面这段,我按下key2后,就进入死循环,串口不停的输出数据key2;单步执行,发现sSCKeyInfo[1].Setting.b.DETECTED的值为1保持不变,只有经过((TSL_GlobalSetting.b.CHANGED) && (TSLState == TSL_IDLE_STATE))这行代码后才变为0;
对这个软件库不熟悉,还请指教如何实现我想要的效果,增加变量也行啊! |
|