Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 115 → Rev 117

/Classwork/ECE4534 - Embedded Systems/PIC 26J11/timers.c
18,8 → 18,12
T0CONbits.TMR0ON = 0; // Timer 0 initially off
 
#ifdef _BASE_STATION
OpenTimer2(TIMER_INT_ON & T2_PS_1_16 & T2_POST_1_16);
T2CONbits.TMR2ON = 0; // Timer 2 initially off
OpenTimer1(TIMER_INT_ON & T1_16BIT_RW &
T1_SOURCE_FOSC_4 & T1_PS_1_1 &
T1_OSC1EN_OFF & T1_SYNC_EXT_OFF,
TIMER_GATE_OFF & TIMER_GATE_INT_OFF);
T1CONbits.TMR1ON = 0; // Timer 1 initially off
overflow_counter = 0;
#endif
#ifdef _REMOTE
// Data polling timer
63,6 → 67,10
MQ_sendmsg_ToMainFromLow(0, MSGTYPE_TIMER1, (void *) 0);
}
#endif
#ifdef _BASE_STATION
MQ_sendmsg_ToMainFromLow(0, MSGTYPE_TIMER1, (void *) 0);
timer1_disable();
#endif
}
 
void timer1_enable() {
76,12 → 84,7
 
// Interrupt handler for timer 2
void timer2_interrupt_handler() {
overflow_counter++;
if (overflow_counter == 50) {
overflow_counter = 0;
timer2_disable();
MQ_sendmsg_ToMainFromLow(0, MSGTYPE_TIMER2, (void *) 0);
}
MQ_sendmsg_ToMainFromLow(0, MSGTYPE_TIMER2, (void *) 0);
}
 
void timer2_enable() {