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.

MSP430G2553: Please tell me about the functions of ADC10

Part Number: MSP430G2553


Hello. My name is Junsuke.

Please tell us about the following events.

The result of dividing the 3.3V power supply of MSP430 by two 10kΩ was converted by ADC10.

The conversion result was 560.My calculation was 511. Why did you get the value of 560?

Below is the programming code used. Thank you.

 

----------

#include  <msp430g2553.h>/* MSP430G2553用のヘッダファイル */
#include  <stdint.h>/* uint8_t とか定義してあるヘッダファイル */
#include<string.h>
#include <stdio.h>
#include <stdlib.h>
char input[10];
char syokika[10]={};
int a;
int mozi;
int kai;
char mukou[64] = {'d','i','s','a','b','\0','e'};
void main(void)
{
   WDTCTL = WDTPW +WDTHOLD;
  BCSCTL1 = CALBC1_1MHZ;
  DCOCTL = CALDCO_1MHZ;
  ADC10CTL0 = ADC10SHT_2 + ADC10ON;
  //ADC10CTL0 &= ~ADC10ON;
/*
 ADC10SHT :ADC10のサンプル&ホールド時間
  (サンプリング・維持の時間設定?)ここでは16カウント
 ADC10ON: ADC10 はオン
 ADC10IE: DC10 割り込みのイネーブル
*/
  ADC10CTL1 = INCH_3;
  ADC10AE0 |= 0b00001000;
  ADC10CTL0 |= ENC;

/*
入力チャンネルをA3に設定
ADC10 アナログ入力のイネーブル(P1.3のアナログ入力をイネーブル(P1.3がA3に対応するため)
 */
  P1DIR |= 0x01;
  P1OUT = 0x01;
  P1SEL = 0x06;
  P1SEL2 = 0x06;
  UCA0CTL1 = 0b10000001;
  UCA0BR0 = 0x68;
  UCA0BR1 = 0x00;
  UCA0MCTL = UCBRS_1;
  UCA0CTL1 &= ~UCSWRST;
  IE2 |= UCA0RXIE;
  __bis_SR_register(LPM0_bits +GIE);
}

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
    if(UCA0RXBUF ==  'a'){
    //ADC10CTL0 |= ENC;
    ADC10CTL0 |=  ADC10SC;
/*ENC : ADC10をイネーブル
ADC10SC: ソフトウェア制御のサンプリング / 変換の開始。*/
    memset(input,'\0',sizeof(input));
    snprintf(input, 10, "%d", ADC10MEM);
    for(mozi=0; mozi<10; mozi++){
                UCA0TXBUF = input[mozi];
                while (!(IFG2 & UCA0TXIFG));
                             }
    char kaigyo[2] = {'\r','\n'};
                        for(kai=0;kai<2;kai++){
                            UCA0TXBUF = kaigyo[kai];
                            __delay_cycles( 10000 );
                        }

----------------------------

 

  • How did you estimate the result?

    You're using SREF=0 (Vcc/Vss). On the G2 Launchpad, Vcc is 3.6V. If you were assuming 3.3V, that might explain a +10% in the result.

    [Edit: Sorry, I did that backwards -- a reading of 560 implies a Vref=Vcc of 1.65/560*1024=3.0V.

    Have you tried measuring the voltage directly at the pin, using e.g. a DMM?

    Another thing to try is extending the sample/hold time, e.g. use ADC10SHT_3 (64 clocks).]

  • Mr. Bruce Thank you for your answer. The result was estimated to be 1.65V, which is the partial pressure of 3.3V. I expected 1.65V to be a digital value of 512 compared to the reference voltage of 3.3V. However, the actual measurement value of the divided point was 1.8V, while the actual measurement value of the power supply voltage was 3.3V. From this, the MSP430 has been measured correctly, but I wonder why the measured value does not reach 1.65V. We have confirmed that there are two 10KΩ external resistors. Thank you

  • What platform are you using? If you're using the G2ET Launchpad, the schematics show an external 47K pullup on P1.3 (A3), which is also connected to a physical button (S1). [Ref G2ET Launchpad User Guide (SLAU772) p. 25]. As I recall different generations of the (older) G2 Launchpad did/didn't have external pullups on the buttons.

    Do you have the option of using A4 (P1.4)? I think that was "undecorated" on all of the G2 Launchpads.

  • I was using G2ET. As you say, using P1.4 gave me the ideal numbers. It seems that the internal pull-up resistor had an effect. Thank you.

**Attention** This is a public forum