Blame | Last modification | View Log | Download | RSS feed
#include <xc.h>#include "main.h"#include "TIMER.h"void TIMER_1_Init(void) {T1CONbits.TMR1CS = 2; // Clock source is ext oscillatorT1CONbits.T1CKPS = 0; // Prescale of 1:1T1CONbits.T1OSCEN = 1; // Dedicated oscillator circuit enabledT1CONbits.nT1SYNC = 1; // Async external clock inputT1CONbits.TMR1ON = 0; // Timer stoppedT1GCONbits.TMR1GE = 0; // Gate disabledTMR1 = 0x8000;PIE1bits.TMR1IE = 1; // Timer 1 overflow interrupt}void TIMER_1_Start(void) {T1CONbits.TMR1ON = 1; // Start timer}void TIMER_1_Stop(void) {T1CONbits.TMR1ON = 0; // Stop timer}void TIMER_1_Interrupt_Handler(void) {LED_LAT = ~LED_LAT;TMR1 = 0x8000;}