Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Configure Timer 2 and start it
- */
- void Timer2_Init(void)
- {
- //* 1. Set the Basic Configuration Register for Timer 2
- //* 2. Set the Clock Source in relation with system Oscillator frequency
- T2CLKCON = 0x06; //sets CS to SOSC freq (pg 440))
- //* 3. T2PSYNC Not Synchronized; T2MODE Software control; T2CKPOL Rising Edge; T2CKSYNC Not Synchronized; Timer Mode
- T2HLT = 0x00; //sets mode to free running with software gate. (424))
- //* 4. T2RSEL set reset source to Pin selected by T2INPPS (pg 443_)
- T2RST = 0x00;
- //* 5. Set PR2 255;
- PR2 = 255; //Timer2 Module Period Register
- //* 6. Set TMR2 Prescale Value to 0
- T2CON |= 0x00; //Prescale is 0
- //* 7. Clearing IF for timer 2
- PIR4 &= 0x01; //clears only the Timer2 interrupt flag
- //* 8. Start Timer2
- T2CON |= 0x80; //turn timer 2 on.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement