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.

MSP430FG6426: MSP430FG6426 ADC working

Part Number: MSP430FG6426

Hi,

Am trying to use ADC of MSP430FG6426 i.e CTSD16. I am getting some reading in CTSD16MEM0. However it is not the decimal value corresponding to the input voltage. Here I have used internal reference voltage i.e 1.16V. so I understand that the range will be from-1.16 to 1.16 with 65535 steps as it is 16 bit ADC. Please correct me if am wrong. If i disable the input reference voltage the default reference voltage would be 3Volts

2. I am m not quite sure about the connection's. Like can I provide the floating voltage supply by connecting the ground of the voltage supply to AVSS. I did this however am getting a garbage value in the ADC buffer. Do I mandatorily have to use the potentiometer with same Vcc and GND as the controller

3. I have referred the user guide but it just confuses me more. I just need to use the single-ended ADC input for the project. Do you have any suggestion on the connections. Also I know a formula used for ADC.

(ADC value/vin=65535/Vref.) . Please let me know if anything otherwise. 

Can you please provide information on this.

Thanks,

Veena

  • Hi Veena,

    1. Please see section 30.2.7.2 for information on this. Your output will be dependent on  the oversampling ratio.
    2. Could you please clarify what voltage supply you are referring to? The ADC should be powered by the same supply as the MSP430. Are you talking about the voltage reference?
    3. There is sample code available on the product page for that device that can help you get started by showing some sample configurations.

    Regards,

    Nathan

  • Hi Nathan,

    Thanks for the response.

    I did use the code. msp430fg662x_ctsd16_05.c . However it is still giving the garbage value in the buffer. Not sure where i am going wrong.

    Is it possible to share the contact details. It gets easier to communicate the issue.

    Regards,
    Veena
  • Hi Nathan,

    1. I am currently using "msp430fg662x_ctsd16_04.c" test code as is for testing purpose. Also I have provided input voltages ranging from 0 to 600mV to P6.4 and Zero to P6.5. With internal refernece voltage 1.16V. as per the calculation for ADC the ADC value/Vin=65535/Vref. Assuming I supplied P6.4=500mV and P6.5=0 volts. Shouldn't I receive the ADC Value as ADC value=(65535/Vref) * Vin i.e ADC value=(65535/1.16)*.6= 33897.41 for offset bit data format. However when I read the value from CTSD16MEM0 it's 27800. Also the ADC conversion never stays stable. I am not sure what I am doing wrong here.

    2. Can you please provide suggestion on what is correct way of providing the input to ADC. or selecting the reference  voltage. What is the expected results for the below test code?

    3. Also the manual says "The full-scale range is defined by VFSR+ = +VR/GAIN and VFSR- = -VR/GAIN; FSR = VFSR+ - VFSR- = 2xVR/GAIN. If VR is sourced externally, the analog input range should not exceed 80% of VFSR+ or VFSR-; that is, VID = 0.8 VFSR- to 0.8 VFSR+. If VR is sourced internally, the given VID ranges apply."  I quite don't understand this calculation. Do I have to set the gain of ADC. The below code does not have any bit to set the gain. 

    #include <msp430.h> 

    unsigned int results; // CTSD16 Conversion Results

    void main(void) {
    WDTCTL = WDTPW | WDTHOLD; // Stop WDT

    P6SEL |= BIT4 | BIT5; // Select AD0+/- analog input pins
    // P5OUT |= BIT3;

    CTSD16CTL = CTSD16REFS; // Internal ref
    // CTSD16CCTL0 |= CTSD16SNGL | CTSD16DF; // Single sample, 2's complement
    CTSD16INCTL0 |= CTSD16INCH_9; // Select AD0+ / AD0- for CH1

    __delay_cycles(2000); // Delay ~120us for 1.2V ref to settle

    while(1) {
    CTSD16CCTL0 |= CTSD16SC; // Set bit to start conversion
    while(!(CTSD16IFG & CTSD16IFG)); // Poll IFG until conversion completes
    results = CTSD16MEM0; // Save CTSD16 conversion results
    // P5OUT = CTSD16MEM0;
    __no_operation(); // SET BREAKPOINT HERE
    }
    }

    Thanks in advance. 

    Regards,

    Veena

  • Hi Veena,

    For MSP430FG6426 i.e. CTSD16

    1. " If i disable the input reference voltage the default reference voltage would be 3Volts ". This is not true if you disable internal reference, CTSD16 does not get any reference voltage.

    2. You just need to connect the ground on your board to ground of your ADC input voltage.

    3. If you want to use single ended ADC input you can still use differential channel and connect ground of external input to negative part of channel or directly use single ended input channel.

    Regards,

    Sanjeev

  • Hi Veena,

    1.  When using "msp430fg662x_ctsd16_04.c" , applying P6.4=500mV and P6.5=0 volts the ADC value, for offset binary output you will get CTSD16MEM0 as CTSD16MEM0  = {(Vin * 32768)/1.16} + 3276 so for your case Vin = 500mV you get CTSD16MEM0 = {(0.5* 32768)/1.16} + 32768 = 46892.13

    2. Provide ADC voltage and make sure both have same ground (connect ground of ADC voltage input to ground of supply on the board you are using).

    3.  If you need to provide gain to input voltage of ADC signal than only you need to set gain. Gain can be set in CTSD16INCTL0 register. By deafult gain = 1. so you should use gain = 1 in formula for calculating VFSR.

    Regards,

    Sanjeev

  • Hi Sanjeev,

    Thank you so much for the response. I will perform the measurements once again keeping in mind your guidelines. 

    Thanks & Regards,

    Veena

**Attention** This is a public forum