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
}
Thank you.