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.

ADC Hardware Oversample unexpected values

Hi there,

I am reading some ADC conversions with and without oversampling (just to find the best option), but oversampling is generating unexpected results.

These are some raw values taken every two seconds WITH hw oversampling (minding only the ISys value):

[3/17 11:26:09.6]= VBatX10 222 | ISys 1544 =
[3/17 11:26:11.6]= VBatX10 222 | ISys 1543 =
[3/17 11:26:13.6]= VBatX10 222 | ISys 1549 =
[3/17 11:26:15.6]= VBatX10 222 | ISys 1546 =
[3/17 11:26:17.6]= VBatX10 222 | ISys 1545 =
[3/17 11:26:19.6]= VBatX10 222 | ISys 1544 =
[3/17 11:26:21.6]= VBatX10 222 | ISys 1543 =

And these are readings under similar conditions, but WITHOUT oversampling set (these are more like the expected values):

[3/17 11:26:29.7]= VBatX10 221 | ISys 1748 =
[3/17 11:26:31.7]= VBatX10 222 | ISys 1770 =
[3/17 11:26:33.7]= VBatX10 220 | ISys 1752 =
[3/17 11:26:35.7]= VBatX10 222 | ISys 1752 =
[3/17 11:26:37.7]= VBatX10 222 | ISys 1762 =
[3/17 11:26:39.7]= VBatX10 222 | ISys 1779 =
[3/17 11:26:41.7]= VBatX10 221 | ISys 1747 =

The configuration for the readings can be seen in the code below (oversample line commented here):

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
	while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_ADC1)));
	// MAP_ADCHardwareOversampleConfigure(ADC1_BASE, 64);
	MAP_ADCSequenceDisable(ADC1_BASE, 0);   // Good practice to disable a sequence before configuring it
	MAP_ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);   // Base1, Sequence0, Processor, Priority0
	MAP_ADCSequenceStepConfigure(ADC1_BASE, 0, 0, ADC_CTL_CH3);		// V_Bat
	MAP_ADCSequenceStepConfigure(ADC1_BASE, 0, 1, ADC_CTL_CH2);		// V_Aux
	MAP_ADCSequenceStepConfigure(ADC1_BASE, 0, 2, ADC_CTL_CH0);		// I_System
	MAP_ADCSequenceStepConfigure(ADC1_BASE, 0, 3, ADC_CTL_CH11);	// I_Extern
	MAP_ADCSequenceStepConfigure(ADC1_BASE, 0, 4, ADC_CTL_CH1);		// I_Charge
	MAP_ADCSequenceStepConfigure(ADC1_BASE, 0, 5, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);  // IC Temperature
	// The last step needs to inform that it is the END, and also causes an interrupt
	MAP_ADCIntClear(ADC1_BASE, 0);  
	ADCIntEnable(ADC1_BASE, 0);
	IntEnable(INT_ADC1SS0);
	MAP_ADCSequenceEnable(ADC1_BASE, 0);

Looking at the signal on a scope does not suggest any ripple, noise or something that could trick the ADC at an oversampling rate, or at least I could not see it.

Any lights as to what could be causing this? Thanks!

  • Hi bruno,

    What exactly are you trying to read? Is it wave or stable voltage?
  • Boa noite Luis Afonso,
    Thanks for the interest. It is a stable voltage. As far as I could see it on the scope (all the way to 70Mhz), it is quite stable.
    For what is worth, it is the current consumption measured by an Allegro ACS712 sensor.
    I would be able to post a scope imagem tomorrow if that helps, but again it is just a flat voltage somewhere near 1.4V if I recall exactly.
    By the way, congrats for your blog, it did help me when dealing with DMA a few weeks ago. I meant to contact you on private and I will do so soon, there's something I'd like to discuss with you, but for now all my "owners" let me is to work on my current project and deliver it.
    Cheers,
  • Boa noite Bruno,

    Hum, I think the only thing that would make the average lower would be a set of values a bit low or a small amount really low. You could make a software average of multiple samples so you can analyze each individual sample to check if that is the case. Though you would need to have a "trigger always" until 64 samples were made to simulate the oversample by hardware. Remember that the maximum sampling speed is pretty high on the ADC and I believe the oversample uses the maximum which for just 1 ADC alone is 500k per second.
    If you are using the launchpad the reference voltage is not exactly precise. I am not sure if with the launchpad is possible to use an external one but it's the best bet if you are measuring current.

    Thanks :D.
    The lack on info on simple DMA use around is actually what made me start the blog.