hello all;
now I am using MSP430F4270, and i’d like to measure the voltage of the battery, if the battery low the microcontroller will give warning.
so i just connect power supply with voltage divider resistor(1.5M and 100K) to A4+ channel analog, but when I debug my program with FET, whenever it takes the ADC result the SD16MEM0 values is always 0xFFFF
when i measure the A4+ pin is only 0.15V, can someone tell me why,
really appreciate for the help,
here is my program…
#include <stdio.h>
#include <math.h>
#include <msp430x42x0.h>
#include “in430.h”
#define LOW_BAT 0xAEEF
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
Init_LCD(); // initialize LCD
Init_Port(); // initialize port
// FLL_CTL0 |= XCAP14PF;
// Delay(4);
Display_all(); // display all character in LCD
Init_ADC();
_EINT(); // enable interrupts
while(1)
{
Display_sign(M,On);
Measure_Bat(); //measure ADC value
}
}
void Init_ADC(void)
{
unsigned int i;
SD16AE |= SD16AE3; // SD16 External Input Enable 4 (A4+ and A4-)
SD16CCTL0 |= SD16SNGL ; // , single conversion mode
SD16INCTL0 |= SD16INCH_4; // SD16 Input Channel select A4
SD16CTL = SD16REFON + SD16SSEL_1; // SD16 Switch internal Reference(1.2V) on, clock source SMCLK
//Delay(6); //delay 5 ms for Vref start up
for (i = 0; i < 0x3600; i++);
unsigned int ADCresult;
void Measure_Bat(void)
{
SD16CCTL0 |= SD16SC; //start conversion
while ((SD16CCTL0 & SD16IFG)==0);
ADCresult = SD16MEM0;
if( ADCresult < LOW_BAT )
{
Display_sign(Bat,On);
}
else
{
Display_sign(Bat,Off);
}