本帖最后由 FSL_TICS_ZJJ 于 2014-1-27 16:42 编辑
先上部分代码
void VoltageChannelChoose(unsigned char chIndex) //电压索引
{
HC138_BCS = 1;//
switch(chIndex)
{
case 0: //第一节电池,SEL0,SEL1导通
AQY210_SEL0 = 0;
HC138_ACS = 0;
HC138_B0 = 0;
HC138_B1 = 0;
HC138_B2 = 0;
break;
case 1: //第二节电池,SEL1,SEL2导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 0;
HC138_B1 = 0;
HC138_B2 = 0;
HC138_A0 = 0;
HC138_A1 = 0;
HC138_A2 = 0;
break;
case 2: //第三节电池,SEL2,SEL3导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 1;
HC138_B1 = 0;
HC138_B2 = 0;
HC138_A0 = 0;
HC138_A1 = 0;
HC138_A2 = 0;
break;
case 3: //第四节电池,SEL3,SEL4导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 1;
HC138_B1 = 0;
HC138_B2 = 0;
HC138_A0 = 1;
HC138_A1 = 0;
HC138_A2 = 0;
break;
case 4: //第五节电池,SEL4,SEL5导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 0;
HC138_B1 = 1;
HC138_B2 = 0;
HC138_A0 = 1;
HC138_A1 = 0;
HC138_A2 = 0;
break;
case 5: //第六节电池,SEL5,SEL6导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 0;
HC138_B1 = 1;
HC138_B2 = 0;
HC138_A0 = 0;
HC138_A1 = 1;
HC138_A2 = 0;
break;
case 6: //第七节电池,SEL6,SEL7导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 1;
HC138_B1 = 1;
HC138_B2 = 0;
HC138_A0 = 0;
HC138_A1 = 1;
HC138_A2 = 0;
break;
case 7: //第八节电池,SEL7,SEL8导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 1;
HC138_B1 = 1;
HC138_B2 = 0;
HC138_A0 = 1;
HC138_A1 = 1;
HC138_A2 = 0;
break;
case 8: //第九节电池,SEL8,SEL9导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 0;
HC138_B1 = 0;
HC138_B2 = 1;
HC138_A0 = 1;
HC138_A1 = 1;
HC138_A2 = 0;
break;
case 9: //第十节电池,SEL9,SEL10导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 0;
HC138_B1 = 0;
HC138_B2 = 1;
HC138_A0 = 0;
HC138_A1 = 0;
HC138_A2 = 1;
break;
case 10://第十一节电池,SEL10,SEL11导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 1;
HC138_B1 = 0;
HC138_B2 = 1;
HC138_A0 = 0;
HC138_A1 = 0;
HC138_A2 = 1;
break;
case 11://第十二节电池,SEL11,SEL12导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 1;
HC138_B1 = 0;
HC138_B2 = 1;
HC138_A0 = 1;
HC138_A1 = 0;
HC138_A2 = 1;
break;
case 12: //第十三节电池,SEL12,SEL13导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 0;
HC138_B1 = 1;
HC138_B2 = 1;
HC138_A0 = 1;
HC138_A1 = 0;
HC138_A2 = 1;
break;
case 13: //第十四节电池,SEL13,SEL14导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 0;
HC138_B1 = 1;
HC138_B2 = 1;
HC138_A0 = 0;
HC138_A1 = 1;
HC138_A2 = 1;
break;
case 14://第十五节电池,SEL14,SEL15导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 1;
HC138_B1 = 1;
HC138_B2 = 1;
HC138_A0 = 0;
HC138_A1 = 1;
HC138_A2 = 1;
break;
case 15://第十六节电池,SEL15,SEL16导通
AQY210_SEL0 = 1;
HC138_ACS = 1;
HC138_B0 = 1;
HC138_B1 = 1;
HC138_B2 = 1;
HC138_A0 = 1;
HC138_A1 = 1;
HC138_A2 = 1;
break;
default:
break;
}
}
程序很简单,但是单步仿真时可以看到switch的索引值是不变的,但是执行完一个分支会跳到别的分支,该执行的分支有的语句也没执行到,用示波器看执行的有现象,不执行的无现象,但是这不是想要的结果啊,网上有人说可能是优化造成的,但是10.4没找到哪里优化啊,希望了解的帮一下。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
你说的不太明白,还请明示
一周热门 更多>