Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
155 Kevin 1
#include <xc.h>
2
#include <delays.h>
3
#include "defines.h"
158 Kevin 4
#include "base_TIMERS.h"
155 Kevin 5
 
6
void Timer1_Init(void) {
7
    T1CONbits.TMR1CS = 0x2;     // Clock source using T1OSC and T1CLK pins
8
    T1CONbits.RD16 = 0x1;       // Configure for 16-bit read/writes
9
    T1CONbits.T1OSCEN = 0x1;    // Enable crystal driver
10
    PIE1bits.TMR1IE = 0x1;      // Enable interrupt
11
 
12
    // Non-applicable settings
13
    T1CONbits.T1CKPS = 0x0;     // 1:1 prescale value
14
    T1CONbits.NOT_T1SYNC = 0x1; // No external sync
15
    T1GCONbits.TMR1GE = 0x0;    // Disable gate control
16
}
17
 
18
void Timer1_Enable(void) {
19
    T1CONbits.TMR1ON = 1;
20
}
21
 
22
void Timer1_Disable(void) {
23
    T1CONbits.TMR1ON = 0;
24
}
25
 
26
void Timer1_Interrupt_Handler(void) {
27
#ifdef _TEST_TIMER1_RTC
28
    TMR1H = 0x7F;
29
    TMR1L = 0xFF;
30
    LED_BLUE_LAT = 1;
31
    LED_RED_LAT = 1;
32
    Delay10KTCYx(255);
33
    LED_BLUE_LAT = 0;
34
    LED_RED_LAT = 0;
35
#endif
36
}