Subversion Repositories Code-Repo

Rev

Rev 147 | Details | Compare with Previous | Last modification | View Log | RSS feed

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