void DelayNS(uint32 dly) { uint32 i;
for(; dly>0; dly--) for(i=0; i<3000; i++); } //持续蜂鸣 int persist(void) { uint32 m; uint32 n; uint32 k; k=0; n=30; for(m=30;m>0;m--) { IO0SET = BEEPCON; // BEEPCON = 1 DelayNS(n); IO0CLR = BEEPCON; // BEEPCON = 0 DelayNS(3); n--; if(n==0) n++; while( (IO0PIN&PIN_P014)==0 ) { IO0SET = BEEPCON; k=k+1; } while( (IO0PIN&PIN_P014)==1 ) if(k>0) IO0SET = BEEPCON; else break; if((IO0PIN&PIN_P014)==0)k=0; } return(0); } 我单步执行看的,运行到最后一个while语句中,判定条件为真,且k=0x00000009时,语句if(k>0) IO0SET = BEEPCON; 不会执行,直接跳出while了,应该是执行了else。是怎么回事阿,k是大于0的呀。 |