調(diào)試ch452l,顯示正常!按鍵響應(yīng)正常!!只是鍵處理執(zhí)行兩次.例如:要按鍵控制某一位顯示加一,但按鍵后顯示卻加二,其余鍵操作也是執(zhí)行兩次??!請高手指教?。椭。?!謝謝!
應(yīng)該是程序問題吧,貼出來看看
/*--------------------------------*/ void int1() interrupt 2 using 1 { flag_in0=1;//按鍵標(biāo)志 } /*---------------------------------*/ jianpan(void) { if(flag_in0==1) { flag_in0=0; aa=CH452_Read(); } } /*------------------------------------*/ void zhixing(void) { switch(aa) {case 0x40:aa=0; CH452_Write(CH452_DIG0 | 0); // 顯示字符8 CH452_Write(CH452_LEFTCYC ); CH452_Write(CH452_DIG7 | 0); break; case 0x49:aa=0; CH452_Write(CH452_DIG0 | 6); // 顯示字符8 CH452_Write(CH452_DIG1 | 6); CH452_Write(CH452_DIG2 | 6); CH452_Write(CH452_DIG3 | 6);;break; case 0x52:aa=0; t++;if(t>9)t=0;CH452_Write(CH452_DIG2 | t); break; case 0x5b:aa=0; CH452_Write(CH452_LEFTCYC ); break; case 0x64:aa=0; CH452_Write(CH452_RIGHTMOV);break; default:break; } } /*-------------主程序-----------------*/ main() { unsigned char cmd,dat,i; unsigned short command; init(); CH452_Write(CH452_SYSON2); CH452_Write(CH452_BCD); // BCD譯碼,8個數(shù)碼管 CH452_Write(CH452_DIG0 | 8); // 顯示字符8 CH452_Write(CH452_DIG1 | 7); CH452_Write(CH452_DIG2 | 6); CH452_Write(CH452_DIG3 | 5); CH452_Write(CH452_DIG4 | 4); CH452_Write(CH452_DIG5 | 3); CH452_Write(CH452_DIG6 | 2); CH452_Write(CH452_DIG7 | 1); /*CH452_Write(CH452_LEFTMOV);//整體左移 CH452_Write(CH452_LEFTCYC );//左循環(huán)移 CH452_Write(CH452_RIGHTMOV);//整體右移 CH452_Write(CH452_RIGHTCYC);//右循環(huán)*/ for(i=0;i<30;i++) while ( 1 ){ jianpan(); zhixing(); } }
init()函數(shù)呢,全部貼出來吧,或者可以發(fā)到技術(shù)部信箱;