本帖最后由 allround 于 2011-8-11 09:22 编辑
最近发现了个怪事,同样的编译器,9.71A和9.80都试过,同样的一段代码,PIC16F690上执行正确,但在PIC12F1822就有问题,下面这段是在16F690上执行正确的,但在1822不对
Esave=buff&0x0f;
switch(Esave)
{
case 0: CNTL^=0xF0; break;
case 1: CNTL^=0xE0; break;
case 2: CNTL^=0xD0; break;
case 3: CNTL^=0xC0; break;
case 4: CNTL^=0xB0; break;
case 5: CNTL^=0xA0; break;
case 6: CNTL^=0x90; break;
case 7: CNTL^=0x80; break;
case 8: CNTL^=0x70; break;
case 9: CNTL^=0x60; break;
case 10: CNTL^=0x50; break;
case 11: CNTL^=0x40; break;
case 12: CNTL^=0x30; break;
case 13: CNTL^=0x20; break;
case 14: CNTL^=0x10; break;
case 15: CNTL^=0x00; break;
default: break;
}
1822的改为下面这段代码就正确了,难道是编译器有问题吗?有人遇到过类似问题没?请指教,谢谢!
if(Esave==0) {CNTL^=0xF0;}
if(Esave==1) {CNTL^=0xE0;}
if(Esave==2) {CNTL^=0xD0;}
if(Esave==3) {CNTL^=0xC0;}
if(Esave==4) {CNTL^=0xB0;}
if(Esave==5) {CNTL^=0xA0;}
if(Esave==6) {CNTL^=0x90;}
if(Esave==7) {CNTL^=0x80;}
if(Esave==8) {CNTL^=0x70;}
if(Esave==9) {CNTL^=0x60;}
if(Esave==10) {CNTL^=0x50;}
if(Esave==11) {CNTL^=0x40;}
if(Esave==12) {CNTL^=0x30;}
if(Esave==13) {CNTL^=0x20;}
if(Esave==14) {CNTL^=0x10;}
if(Esave==15) {CNTL^=0x00;} |