ADC Initialization on VS1010

Using VSDSP legacy command line tools.
Post Reply
avizet
Senior User
Posts: 28
Joined: Tue 2021-06-29 11:25

ADC Initialization on VS1010

Post by avizet »

Hi!

Currently I'm working on ADC initialization using vs1010d (QFN68). I'm trying replicate the below msp430 ADC12 initialization. So, how can I do that in VS1010d.

Code: Select all

/*****************************************************************************
* Module       : configure_ADC12_channels
* Description  : configures ADC channels with reference/interrupt/memory buffer
*              : A5     - LAT
*              : A13    - CO
*              : A14    - primary cell voltage - not used now
*              : A15    - secondary LiPO cell voltage
* Return       : void
******************************************************************************/
void configure_ADC12_channels(){
    // Configure analog pins
    // Temperature - A5
    P1SEL1 |= BIT5;
    P1SEL0 |= BIT5;
    // CO, Primary batt & LiPo batt - A13, A15
    P3SEL1 |= BIT1 | BIT3;
    P3SEL0 |= BIT1 | BIT3;

    // Configure ADC12
    ADC12CTL0 = ADC12SHT0_4 | ADC12ON | ADC12MSC;    	// 64 cycles SHT for stable read
    ADC12CTL1 |= ADC12SHP | ADC12CONSEQ_1;    			// ADCCLK = MODOSC; sampling timer??????
    ADC12CTL2 |= ADC12RES_2;                  			// 12-bit conversion results
    ADC12IER0 |= ADC12IE2;                    			// Enable ADC conv complete interrupt

#ifdef INTERNAL_VREF
    ADC12MCTL0 |= ADC12_B_VREFPOS_AVCC_VREFNEG_VSS | ADC12INCH_5;  // A5 - Temperature; Vref= internal 2.7
    ADC12MCTL1 |= ADC12_B_VREFPOS_AVCC_VREFNEG_VSS | ADC12INCH_13; // A13 - CO; Vref= internal 2.7
    ADC12MCTL2 |= ADC12_B_VREFPOS_AVCC_VREFNEG_VSS | ADC12INCH_15 | ADC12EOS; // A15 - LiPo voltage; Vref= internal 2.7
#else
    ADC12MCTL0 |= ADC12_B_VREFPOS_EXTPOS_VREFNEG_EXTNEG | ADC12INCH_5;  // A5 - Temperature; Vref= external 2.048
    ADC12MCTL1 |= ADC12_B_VREFPOS_EXTPOS_VREFNEG_EXTNEG | ADC12INCH_13; // A13 - CO; Vref= external 2.048
    ADC12MCTL2 |= ADC12_B_VREFPOS_EXTPOS_VREFNEG_EXTNEG | ADC12INCH_15 | ADC12EOS; // A15 - LiPo voltage; Vref= external 2.048
#endif
    // settling time
    __delay_cycles(10000);
    ADC12CTL0 |= ADC12ENC;    // Enable ADB_12
}
Need your help here.

Thank you.
Hannu
VLSI Staff
Posts: 532
Joined: Mon 2016-05-30 11:54
Location: Finland
Contact:

Re: ADC Initialization on VS1010

Post by Hannu »

Here's some previous posts about SAR. I hope those help you.

viewtopic.php?p=14421#p14421

This is little bit dated solution. When ReadVoltage was released, AVVCD was used as reference. Now 2 x VREF is used as reference. VREF is 1.2V or 1.6V depending if you set ANA_CF0_HIGH_REF bit also. So your 4095 value would be that voltage. So some modifications needed, but that's just small mathematics.

viewtopic.php?p=11227#p11227
Post Reply