I'm trying to use the DTC to continuously update a variable without CPU intervention. However I am not getting any results and cannot figure out why. Any help would be appreciated.
Here is the method to initialize the DTC:
void initializeDTC(unsigned int channel,unsigned int *pointer){
// Disable ADC before configuration.
ADC10CTL0 &= ~ENC;
// Turn ADC on in single line before configuration.
ADC10CTL0 = ADC10ON;
// Set channel, Use SMCLK, 1/8 Divider, Repeat single channel.
ADC10CTL1 = channel | ADC10SSEL_3 | ADC10DIV_7 | CONSEQ_2;
// 0 clock ticks, Use Reference, Reference on, ADC On, Multi-Sample Conversion, Interrupts enabled.
ADC10CTL0 |= ADC10SHT_1 | SREF_1 | REFON | MSC | ADC10IE;
// Put results at specified place in memory.
ADC10SA = (unsigned int)pointer;
// Only one conversion at a time.
ADC10DTC1 = 0x01;
// Repeat conversion.
ADC10DTC0 = ADC10CT;
// Start conversion.
ADC10CTL0 |= ENC | ADC10SC;
// I've read that trying to start the conversion twice is necessary.
ADC10CTL0 |= ENC | ADC10SC;
}
I call it like this:
unsigned int temperature;
initializeDTC(INCH_10, &temperature);
// Do stuff with temperature in a loop.
If I've understood the documentation correctly, after each conversion the ADC should start the next conversion because of the MSC bit. At the same time the DTC should transfer the value of ADC10MEM to the value in address in ADC10SA (the value of my pointer). The value of my temperature variable remains at the default value of whatever was in the memory previously (35 thousand and something for me).