This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F4270 SD16_A problem

Other Parts Discussed in Thread: MSP430F4270

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 |= SD16AE4;                              // SD16 External Input Enable 4 (A4+ and A4-)
 
  SD16CCTL0 |= SD16UNI ;      // , Unipolar 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;
    SD16CCTL0 &= ~SD16SC;
    if( ADCresult < LOW_BAT )
   {
    Display_sign(Bat,On);
  
   }
   else
   {
    Display_sign(Bat,Off);
  
   }

  • My recommendation is the following:
    1. Download and test the code example "msp430x42x0_sd16a_05" from the following zip file:
    http://www.ti.com/lit/zip/slac077

    2. Test the above code example "AS-IS" by tying A0+/A0- to GND and then change it to test with A4+ and A4-. Tie A4+ and A4- to GND and then something that will give to another reading (ay be 0xFFFF). Please note the different types of data formats used by SD16 to read the input on pg 29-12 of the user's guide.

    A few other things to note are:

    1. Connect a 100nF capacitor when using internal ref per User's Guide, section 29.2.3:

    http://www.ti.com/litv/pdf/slau056h


    2. Connect a 470nF cap when providing internal ref off-chip (VMIDON = 1) per User's Guide.

    3. Calibrate gain Amplifier using A7 (device to device).

    4. Keep within SD16 freq & Vcc range (per datasheet).

    5. We recommend decoupling capacitors of 10 uF (Tantalum) and 0.1 uF (Ceramic) as close to Vcc Pin on the MSP430. It may also be a good idea to put some decoupling capacitors on the SD16 input pins to filter noise.

  • thanks for the reply, I ve already folllow to connect 100 nF. iuased Unipolar output mode to have voltage range of 0.6 Volt

  • Nandax,

    One quick point;

    The SD16AE bit setting in your code needs to be rechecked.

    Refer to this post for information on how to use the SD16AE register: http://e2e.ti.com/forums/p/3130/11604.aspx#11604

    In your case i.e. the F4270 :

     A4+ is P1.3 --> SD16AE3 needs to be set

    A4- is P1.2  --> SD16AE2 is set if negative input is used, cleared if its gnded.

    Please fix this in your code and let us know if it solves the issue.

    -Priya

     

  • Priya said:

    Nandax,

    One quick point;

    The SD16AE bit setting in your code needs to be rechecked.

    Refer to this post for information on how to use the SD16AE register: http://e2e.ti.com/forums/p/3130/11604.aspx#11604

    In your case i.e. the F4270 :

     A4+ is P1.3 --> SD16AE3 needs to be set

    A4- is P1.2  --> SD16AE2 is set if negative input is used, cleared if its gnded.

    Please fix this in your code and let us know if it solves the issue.

    -Priya

     

    but, if that is how you set the analog pin,

    how can you set A4- and A1+

    because A4- is p1.2

    and A1+ is P6.2 --- do i have to use SD16AE2 twice ? 

    i've 'change with A4+ is P1.3 --> SD16AE3

    but i still get 0xFFFF in SD16MEM0

  • can someone help me please...

  • I am not too familiar with the chip you are using, but looking at the datasheet, the analog inputs for the ADC channels on the P6.x pins are enabled by setting the P6SEL.x bits (http://focus.ti.com/lit/ds/symlink/msp430f4270.pdf page 50 and 51). 

    Also, I am not sure why you are trying to read the conversion results of ADC channel 4 out of ADC channel 0 conversion memory register (http://focus.ti.com/lit/ug/slau056h/slau056h.pdf section 29.2.8)

    Sparkchaser

  • Nandax,

    Not all SD16 pins need an SD16AE initialization. The information you are looking for is available in the Input/Output Schematics section of the Datasheet.

    This tells you which bits need to be set based on the functionality of the port pin required.

    For example to select A1+ functionality for P6.2 you only need to set P6SEL |= BIT2;

    Regards,

    Priya

**Attention** This is a public forum