Subversion Repositories Code-Repo

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/* The processor calls these handlers when an interrupt is triggered */
#include "maindefs.h"
#include "msg_queues.h"
#include <timers.h>
#include "timers.h"
#include "adc.h"
#include "xbee.h"

void timers_init() {
    /*--------------------Timer Delay Formulas-------------------- */
    /* InitTMR0 = 256 - ( Delay * Frequency ) / ( 4* Prescaler)    */
    /* Delay = (256 - InitTMR0 * Prescaler) / (Frequency / 4)      */
    /* ----------------------------------------------------------- */

    // Set timer 0 to overflow every 512 clocks
//    OpenTimer0(TIMER_INT_ON & T0_8BIT & T0_SOURCE_INT & T0_PS_1_256);
    
    // Set timer 1 to overflow every two seconds
//    OpenTimer1(TIMER_INT_ON & T1_16BIT_RW &
//                T1_SOURCE_PINOSC & T1_PS_1_1 &
//                T1_OSC1EN_ON & T1_SYNC_EXT_OFF,
//                TIMER_GATE_OFF & TIMER_GATE_INT_OFF);

    // Open timer 2 for CCP1 (PWM)
    OpenTimer2(TIMER_INT_OFF & T2_PS_1_4 & T2_POST_1_1);
}

// Interrupt handler for timer 0
void timer0_interrupt_handler() {
//    xbee_process_transmit_frame_interrupt();

}

// Interrupt handler for timer 1
void timer1_interrupt_handler() {
    // Set timer to overflow every 10ms
    WriteTimer1(62259);

//    xbee_process_transmit_frame_interrupt();
}