I am trying to repeatedly sample one channel from the ADC on my MSP430FR5969 using timer TA0. Unfortunately, the timer doesn't appear to be causing conversions. I expect my issue lies in my configuration of the ADC control registers.
void init()
{
// Set up clock
CSCTL0_H = CSKEY >> 8; // Unlock CS registers
CSCTL2 |= SELA__LFMODCLK; // Set ACLK= MODCLK / 128
CSCTL3 |= DIVA__1; // Set divider for ACLK = 1
CSCTL0_H = 0; // Lock CS registers
// Set up timer
TA0CCR0 = 4; // Period (should come to ~7.5kHz)
TA0CCTL1 = OUTMOD_3; // CCR1 reset/set
// Set up ref voltage
REFCTL0 = REFVSEL_2 | REFTCOFF | REFON; // Set reference voltage to 2.5V
// Set up ADC
ADC12CTL0 = ADC12SHT0_0 | ADC12ON; // Sampling time, ADC12 on
ADC12CTL1 = ADC12SHS_1; // Use TA0.1 as sample and hold source
ADC12CTL2 = ADC12RES__12BIT; // 12-bit conversion results
ADC12MCTL0 |= AUDIO_PIN | ADC12VRSEL_1; // A15 ADC input select; Vref=2.5V
ADC12IER0 |= ADC12IE0; // Enable ADC conv complete interrupt
ADC12IFGR0 &= ~ADC12IFG0; // Clear interrupt flag
}
void start_samples()
{
// Enable conversions
ADC12CTL0 |= ADC12ENC;
// Enable timer
TA0CTL = TASSEL__ACLK | MC__UP | TACLR;
// Enter LPM3, enable interrupts
__bis_SR_register(LPM3_bits | GIE);
__no_operation();
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
// Push sample to buffer
*dst++ = ADC12MEM0;
}