Re: 請問使用Timer2來做Delay Time的問題
|
||||
---|---|---|---|---|
新會員
|
Dear yiming:
感謝你的詳解~
發表於: 2007/7/3 17:35
|
|||
|
請問使用Timer2來做Delay Time的問題
|
||||
---|---|---|---|---|
新會員
|
Dear 各位高手:
使用Fosc 16MHZ,依計算DELAY TIME應該為1m sec (4/16M)*4*10*100=1m sec 但我用示撥器看ㄉ結果卻為100u sec 請各位高手幫我看看何處有問題ㄋ?感謝!!! 程式如下: #include <p18f452.h> #include <timers.h> void Delay_Timer2(void); void main() { ADCON1=0b00000110; T2CON =0b01001001; PR2=99; TRISD=0x00; PORTD=0x01; while(1) { PORTDbits.RD0=~PORTDbits.RD0; Delay_Timer2(); } } void Delay_Timer2(void) { TMR2=0; T2CONbits.TMR2ON=1; while(TMR2<PR2); { } T2CONbits.TMR2ON=0; }
發表於: 2007/6/26 16:14
|
|||
|