For PIC24 what do each instruction do Assume the oscillator
For PIC24 what do each instruction do ?
Assume the oscillator is running at 8 MHz. Add useful explanatory comments to the following configuration instructions, then tell how long the timer will run before setting the T2IF flag. T2CONbits.TON = 0; T2CONbits.TSIDL = 0; T2CONbits.GATE = 0; T2CONbits.TCKPS = 0b01; T2CONbits.T32 = 0; T2CONbits.TCS = 0; PR2 = 1624; TMR2 = 0; T2IF = 0; T2CONbits.TON = 1;Solution
Ans)
T2CONbits.TON = 0; // Stop any 16/32-bit Timer2 operation
T2CONbits.TSIDL = 0; // Continue timer operation in Idle mode
T2CONbits.GATE = 0; // Disable Gated Timer mode
T2CONbits.TCKPS = 0b01; // Select 1:8 Prescaler
T2CONbits.T32 = 0; // TMRx and TMRY form separate 16-bit timer TMRY is a Type C timer (Y = 3, 5, 7 and 9).
T2CONbits.TCS = 0; // Internal clock (FOSC/2)
PR2 = 1624; // Load 16-bit period value
TMR2 = 0; // Clear 16-bit Timer
T2IF=0;// Clear Output Compare 1 interrupt flag
T2CONbits.TON = 1; // Start 16-bit Timer
---------------------------------
Foc=8 MHz
Prescaler=8
So Timer Frequency =(Foc/2)/8=0.5 MHz=500kHz
Delay Time =Period Count*1/500k=1624*1/500k=3.248 msec
So Time will run for 3.248 sec before setting Flag
