This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC10 Question?



Hi,

I'm using ez430-rf2500 10-bit ADC to sample audio signal but i don't understand some part of ADC10 registers. I'll use ADC10 analog input A0. Vref=1.5V (internal). Here is my code.

ADC10CTL1 = CONSEQ_2;
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + MSC + ADC10ON + ADC10IE;
TACCR0 = 30;                              // Delay to allow Ref to settle
TACCTL0 |= CCIE;
TACTL = TASSEL_2 + MC_1;
__bis_SR_register(LPM0_bits + GIE);
TACCTL0 &= ~CCIE;
ADC10AE0 |= 0x01;

Shall i use INCHx bits in addition to ADC10AE0 or is ADC10AE0 enough for indicate analog input A0?

I don't understand ADC10SHTx 's effect? For example what is going to be if i use 8 x ADC10CLKs instead of 16 x ADC10CLKs? Is it about sampling rate?

I want to sample repeatedly so i used CONSEQ_2 and MSC. Is it ok or else shall i use another code for sample repeatedly?

If i want to trig adc conversion using timer A, isn't it make without an external watch crystal?

  • Of course you need to tell the ADC10 from which input source to sample. The ADC10AExy registers only configure the port pins for analog usage instead of digital I/O.

    YOu can enable one or all and still want to sample a specific one at a given time. Also, the AE registers don't have bits for the internal data sources such as the temp sensor. So yes, you need to set INCHx.

    About SHTx and ADC10SR, yes, it is about sampling rate. Or, more precisely, it is about sampling time. The ADC10 uses a sample and hold mechanism. Basically, it is a small capacitor loaded for a certain time and then sealed from the input while the actual conversion takes place (so input changes while converting do not affect the conversion). The more time you give this capacitor to load, the more precise your reading will be. How much is required and how much is useless depends on the impedance of your voltage source. Simplified, the lower the impedance of your voltage source (e.g. direclty reading a battery voltage is very low inpedance), the shorter SHTx setting is required. Also, this settign acts as sort of a low pass filter, limiting the inputs bandwidth (spikes shorter than the SHT will be ignore or at least dampened). This is described in detail in chapter 20.2.5 of the family users guide slau144e.pdf.

    As a side effect, the higher the SHTx setting is, the more time is required per conversion and the lower is the maximum resulting sampling rate. The conversion itself is 13 ADC10Clock cycles so the total conversion time is SHTx + 13 clock cycles (= 17/21/29/77) and the maximum sampling rate is ADC10CLK/17(21/29/77). The value(range) of ADC10CLK is found in the device specific datasheet (not int the family users guide)

    Depending on the result of this calculation, (and whether you really initiate conversions that often), you should perhaps set or clear ADC10SR. Setting it reduces power consumption. But keep in mind that this refers to the peak frequency formed by two consecutive conversions, not to the average frequency, as it directly controls the load current for the internal voltage reference. Operating at the edge decreases reference voltage precision.

    Looking through your code, there's one thing at first: you need to clear ENC, then set up the ADC10, then set ENC. As long as ENC is set, many bits in ADC10CTLx are not settable. And unless it is set again, the ADC10 won't do anything. It is important to do it in separate steps. You cannot set e.g. SREF and ENC together.

    If you use CONSEQ_2, the ADC10 will, once started, perform conversions at its maximum speed. Each conversions sample cycle will be , however, synchronized with the S-H-Source, which you left assigned to ADC10CLK in your code. This means next conversion will start with the next ADC10CLK tick. If you want to synchronize it with TimerA, you need to set SHSx properly and also program TimerA CCR0/1/2 to invert its out bit if the time expired.

     

**Attention** This is a public forum