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.

what is my sampling rate

what is my sampling rate or number of samples/second in my program

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT

BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;


ADC10CTL1 = INCH_1 + CONSEQ_2; // A1/A0, repeat channel
ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;
ADC10AE0 = 0x03; // P1.0,1 ADC option select
ADC10DTC1 = 0x20; 

for (;;)
{
ADC10CTL0 &= ~ENC;
while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active
ADC10SA = 0x200; // Data buffer start
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion ready
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit

}
}

// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}

  • It is not obvious!

    One way to find out for sure - put an output toggle inside of your isr.

     

  • Hi qwert,

    It seems like you are using ADC10OSC which has a frequency around 3.7Mhz-6.3Mhz (for G2xx2, check datasheet).

    The sample frequency for the ADC will be ADCCLK/(sample_and_hold + conversion_time + sync).

    Your sample and hold is 16 cycle (ADC10SHT = 10),  the conversion time for ADC10 is 13 cycles (per datasheet), and the sync will be ~0-1 cycle.

    So, each conversion will take between 4.6us-8.1us. You are using repeated-single-channel, so A1 will be sampled at this frequency.

    Since you are using the DTC, you are taking 32 samples, so the whole sequence will take ~147us-259us (or 3.85khz-6.78khz).

    Note that the main loop disables and re-enables the sequence, so the actual time from interrupt to interrupt might be different. 

    For more accurate results, consider using SMCLK as the source for your ADC, and/or trigger the ADC using a timer.

    Regards,

    Luis R

  • Questions worded like this always make me wonder if TI just did someone's homework problem for them.

**Attention** This is a public forum