HI Robert Chen i did the following changes but still when i reduce the battery voltage below 2.5V CBOUT remains 1 no change in CBOUT , are my CBTLx settings proper??? #include #include #include int main (void) { int Batt; WDTCTL = WDTPW + WDTHOLD; ///Stop the watch dog timer REFCTL0 = REFVSEL_2|REFOUT|REFON; //Turn ON the reference module to enable 2.5V reference CBCTL0 = CBIPEN + CBIPSEL_0; /// enable CB0 as +V terminal of comparator CBCTL1 = CBPWRMD_1 + CBFDLY_1 + CBF; /// normal power mode, filter delay to 900ns, output to be filtered CBCTL2 = CBREFL_3 + CBRSEL + CBRS_1; /// reference of 2.5V, select V- terminal were 2V is applied CBCTL1 = CBON; /// Turn ON the comparator while(1) { Batt = CBCTL1 & CBOUT; if (Batt == 0x0001) { P4DIR |= BIT7; ///glow led if CBOUT=1 P4OUT = BIT7; } else { } } }
↧