I believe you must trip the ENC flag to start the ADC process. I have not used
the MSP with the ADC10 module, only those with the ADC12.


Try the following snippet from my code which runs successfully at 40 kHz.
(Although, my ADC routine is within an interrupt) Place it before your for(;;)
loop.

   ADC12CTL0 &= ~ENC;   // Ensure Low .. When again placed high, ADC will arm
for operation
   ADC12CTL0 |=  ENC;     // Now armed to run!




Cheers
Harry



-----Original Message-----
From: mspgcc-users-ad...@lists.sourceforge.net
[mailto:mspgcc-users-ad...@lists.sourceforge.net]on Behalf Of Robert Scott
Sent: Wednesday, June 30, 2004 1:23 AM
To: mspgcc-users@lists.sourceforge.net
Subject: [Mspgcc-users] Problems with ADC10 trigged by TA1

Hi!

I'm working with a project where I want to trig the ADC10 at 64 kHz by using the
Timer A Out 1.
I can't figure out what I'm doing wrong, please help me, I'm going nuts... or is
it ballistics?
Hmmm... Anyway, here's a copy of the "important" code:

Thanks in advance for any help, any help at all! :)
/Robert

int16_t main(void)
{
  uint8_t Channel;
  uint8_t i;
  uint16_t tmpSample;
  WDTCTL = WDTPW | WDTHOLD;             // Stop WDT
  BCSCTL1 |= XTS;                       // ACLK = LFXT1 = HF XTAL
  do
  {
    IFG1 &= ~OFIFG;                     // Clear OSCFault flag
    for (i = 0xFF; i > 0; i--);         // Time for flag to set
  }
  while ((IFG1 & OFIFG) != 0);          // OSCFault flag still set?

  BCSCTL2 |= (SELM_2|SELS);             // MCLK = LFXT1 (safe), SMCLK = LFXT1CLK

  /*
  Setup ADC10
  VR+ = VREF+
  VR- = AVSS
  Internal reference 2,5 Volt
  ADC10 Sample-and-hold time: 16 x ADC10CLK

  A2 used for ADC10 input.
  Sample-and-hold trigged by Timer A Out 1;
  ADC10CLK = ACLK
  */

  ADC10CTL0 = (SREF_1|ADC10SHT_2|REF2_5V|REFON);
  ADC10CTL1 = (INCH_2|SHS_1|ADC10DIV_0|ADC10SSEL_1|CONSEQ_2);
  ADC10AE   = (0x04);

  /*
  Setup Timer A
  clock source: ACLK
  /1
  One tick each 125:e klockcykel (15.625 us @ 8MHz)
  */
  TACTL = TASSEL_ACLK | ID_DIV1 | MC_STOP;
  CCR0 = 125;
  CCR1 = 120;
  TACCTL1 = OUTMOD_2;

  ADC10CTL0 |= ADC10ON;

  TACTL |= MC_UPTO_CCR0;

  for(;;)
  {
    for(Channel = 0 ; Channel < CHANNELS_PER_SENSOR ; Channel++)
    {
      SetChannel(Channel);                    // Setup external mux
      while (!(ADC10CTL0 & ADC10IFG));        // PROGRAM STOPS HERE!

      ADC10CTL0 &= ~(ADC10SC|ENC|ADC10IFG);
      ADC10CTL0 |= ENC;
      tmpSample = ADC10MEM;                   // Read sample
    }
  }
  return 0;
}

Reply via email to