void setup_clocks_xt2 (void) {
int i;
BCSCTL1 = DIVA_0 ;
do {
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 50; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG));
BCSCTL2 = SELM_2 + DIVM_0 + SELS + DIVS_3;
}
// ===========================================
// Setup CPU timers
// ===========================================
void setup_timers(void) {
// Timer B0 interrupt service routine 10 time base
#pragma vector=TIMERB0_VECTOR
__interrupt void Timer_B0 (void) {
//keytimebase++;
current_on();
rep_timer1++; rep_timer2++;
key_sel_timer++;
backlight_timer++; battery_timer++; bootup_timer++;
if (display_count) display_count--; else display_refresh();
if (delay_count) delay_count--;
mstimer_count++;
if (mstimer_count>=100) { // 1 second
mstimer_count=0;
menu_scale_timer++;
if (menu_scale_timer>30) { // 30 seconds
menu_scale_timer=0;
menu_scale=0;
}
return_timer++;
if (return_timer>=30) {
return_timer=0;
return_detector();
}
}
}
// CCR2 to CCR6 you can control by PWM mode
// or time phase control
#pragma vector=TIMERB1_VECTOR
__interrupt void Timer_B1 (void) {
switch( TBIV ) {
case 2: // CCR1 interrupt (never)
break; //
case 4: // CCR2 interrupt
break;
case 6: // CCR3 interrupt
break;
case 8: // CCR4 interrupt
break;
case 10: // CCR5 interrupt
break;
case 12: // CCR6 interrupt
break;
case 14: // timer overflow same as timer B0