問(wèn)題1 CH558 TIMER2捕捉模式時(shí),對(duì)T2EX引腳的脈沖進(jìn)行捕捉,請(qǐng)問(wèn)如何對(duì)TIMER2計(jì)數(shù)器的計(jì)數(shù)溢出進(jìn)行計(jì)數(shù)?
我做試驗(yàn)時(shí),在timer2中斷程序中用UINT8 cnt對(duì)溢出中斷計(jì)數(shù),但發(fā)現(xiàn)cnt計(jì)數(shù)經(jīng)常溢出且TIMER2溢出中斷頻率很快.中斷程序如下:
/*******************************************************************************
* Function Name? : mTimer2Interrupt()
* Description??? : CH559定時(shí)計(jì)數(shù)器2定時(shí)計(jì)數(shù)器中斷處理函數(shù)
*******************************************************************************/
void?? ?mTimer2Interrupt( void ) interrupt INT_NO_TMR2 using 2???? //timer2中斷服務(wù)程序,使用寄存器組1
{
???? mTimer2RunCTL( 0 );?????????????????????????????????????????????????????? //關(guān)定時(shí)器
? ?? cnt++;
?? ?? LED=!LED;
??? if(EXF2)??????? //T2ex電平變化中斷中斷標(biāo)志
??? {
????? EXF2 = 0;???????????????????????????????????????????????????????????? //清空T2ex捕捉中斷標(biāo)志?? ??? ?
?? ?? count0 = count1;??????????? //備份上一次的捕獲值
???? ? ((UINT8 *)&count1)[3] = RCAP2L;? //保存本次的捕獲值
?????? ((UINT8 *)&count1)[2] = RCAP2H;
?????? ((UINT8 *)&count1)[1] = cnt;
?????? ((UINT8 *)&count1)[0] = 0;
?????? length = count1 - count0;?? //計(jì)算兩次捕獲的差值,即得到時(shí)間長(zhǎng)度
?? ????? ((UINT8 *)&length)[0] = 0;
?? ????? finshFlag=1;?? ?
??? }
?? mTimer2RunCTL(1 );???
?}
問(wèn)題2:選用內(nèi)部12M 時(shí)鐘,如果不用CfgFsys( ) 函數(shù)配置,是否Fsys=Fosc=12M? 另外請(qǐng)問(wèn)MASK_PLL_MULT如何設(shè)置PLL時(shí)鐘倍頻系數(shù)?因?yàn)閺?fù)位值是11000b=18(hex),如果我要PLL倍頻2倍,如何設(shè)置MASK_PLL_MULT?
謝謝!