EmbeddedRelated.com
Forums

MSP430F2132 ADC10 DTC Problem

Started by bb_stefan June 23, 2009
Hi all,

I have a strange behaviour with the DTC controller which I stumbled over by pure chance.
After POR/PUC I initialize ADC10 as follows:

// *** Setup ADC10 ***
ADC10CTL0 &= ~ENC;
ADC10CTL1 = INCH_6+SHS_0+ADC10SSEL_2+ADC10DIV_1
+CONSEQ_1;
ADC10CTL0 = SREF_2+ADC10SHT_2
+MSC+ADC10ON+ADC10IE;
ADC10AE0 = 0x6B;
ADC10DTC0 = 0x00;
ADC10DTC1 = 0x07;
ADC10SA = (unsigned int)&AdcVal;
ADC10CTL0 |= ENC;

That is sequence-of-channels (A6-A0), physically not using A2, A4.
DTC for automatically transferring the 7 conversion results in one-block mode and IRQ after one-block transfer has finished.
After this init the DTC is in IDLE (User-Guide, State-Diagram 20-10)
and waiting for ADC10MEM to be written to.
After initialization, ADC measurement ist startet every 100ms and in the corresponding ADC10-ISR I do again a write to ADC10SA:

// *** ADC10_Interrupt ***
...
ADC10SA = (unsigned int)&AdcVal;
...

to IDLE again the DTC according to User-Guide, State Diagram 20-10.
Everything works fine ;-)
BUT....
If I do a SW-reset (WDT access w/o password) or let the WDT expire, a PUC is generated, leading to another initialization as described above.
But then the DTC is not working any more. ADC10 conversion works, as I can see in a plausible conversion result in ADC10MEM,
but DTC is not initiated and therefore no IRQ is generated.

It seems, that DTC keeps in IDLE-State after PUC and writing to ADC10SA (in the init) deactivates DTC instead of putting it in IDLE as intended.
My workaround is to first reset DTC by setting ADC10DTC1 = 0x00 at initialization before activating:

// *** Setup ADC10 ***
ADC10CTL0 &= ~ENC;

ADC10DTC1 = 0x00; <-- RESET DTC

ADC10CTL1 = INCH_6+SHS_0+ADC10SSEL_2+ADC10DIV_1
+CONSEQ_1;
ADC10CTL0 = SREF_2+ADC10SHT_2
+MSC+ADC10ON+ADC10IE;
ADC10AE0 = 0x6B;
ADC10DTC0 = 0x00;
ADC10DTC1 = 0x07;
ADC10SA = (unsigned int)&AdcVal;
ADC10CTL0 |= ENC;

I don't know if this is a bug or if it is intended...
... but I think it is not obviously clear from reading the user-guide...?!
Anyone else out there having similar problems... or solutions?

Beginning Microcontrollers with the MSP430

Update:

In the meantime I had contact to TI customer support.
They confirm, that there is a "problem" that DTC is not resetted after PUC. So they recommend resetting DTC manually after PUC in the way I proposed and also implemented in my code:

// *** Setup ADC10 ***
ADC10CTL0 &= ~ENC;
while(ADC10CTL1 & ADC10BUSY);
ADC10DTC1 = 0x00; <-- RESET DTC

They also confess the fact, that the user guide documentation is not clear enough and therefore will be updated accordingly.