please help with sd16_A in msp430

Discussion in 'Embedded Systems and Microcontrollers' started by nandax, Aug 3, 2009.

  1. nandax

    Thread Starter Member

    Nov 20, 2008
    12
    0
    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 code..

    #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);

    }
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    If that is 5 volts, the most you can get out of the divider is 315 millivolts if the big resistor is on top. The input impedance of the A to D pin is probably small enough that it causes the other drop. Try 100K & 100K.
     
  3. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Please post your schematic.

    Also have you tried looking at TI's appnote for using this adc?

    Please use the CODE tags and post your complete code... what you have there is hard to read and looks like it is missing curly braces and such. If you have nicely formatted and commented code people are more likely to take time to help. Help us help you ;)
     
Loading...