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.

ADCSequenceStepConfigure clarification

I am using this function as I am following the TIVAWare workshop. But I do not understand some arguments of this function. I am new to the TIVA and ARM microcontrolers. I have already refereed the data sheet and the API guide I still am not having a clear picture of this function.  Is it possible to know the meaning of the digits inside the arguments of this function? --> ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS); ?

Your help will be so much appreciated.

Following is my code.

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"
#define TARGET_IS_BLIZZARD_RB1
#include "driverlib/rom.h"

int main(void)
{
	//create an array
	uint32_t ui32ADC0Value[4];
	volatile uint32_t ui32TempAvg;
	volatile uint32_t ui32TempValueC;
	volatile uint32_t ui32TempValueF;
	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	ADCHardwareOversampleConfigure(ADC0_BASE, 64); // enabling hardware averaging

	ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);

	ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);

	ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
	ADCSequenceEnable(ADC0_BASE, 1);
	while(1)
	{
		ADCIntClear(ADC0_BASE, 1);
		ADCProcessorTrigger(ADC0_BASE, 1);
		while(!ADCIntStatus(ADC0_BASE, 1, false))
		{
		}
		ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
		ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4;
		ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;
		ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5;
	}
}



I got the following from the API guide. It is an abstraction.

ADCSequenceStepConfigure
Configure a step of the sample sequencer.
Prototype:
void
ADCSequenceStepConfigure(uint32_t ui32Base,
uint32_t ui32SequenceNum,
uint32_t ui32Step,
uint32_t ui32Config)
Parameters:
ui32Base is the base address of the ADC module.
ui32SequenceNum is the sample sequence number.
ui32Step is the step to be configured.
ui32Config is the configuration of this step; must be a logical OR of ADC_CTL_TS,
ADC_CTL_IE, ADC_CTL_END, ADC_CTL_D, one of the input channel selects
(ADC_CTL_CH0 through ADC_CTL_CH23), and one of the digital comparator selects
(ADC_CTL_CMP0 through ADC_CTL_CMP7).
Description:
This function configures the ADC for one step of a sample sequence. The ADC can be
configured for single-ended or differential operation (the ADC_CTL_D bit selects differential
operation when set), the channel to be sampled can be chosen (the ADC_CTL_CH0
through ADC_CTL_CH23 values), and the internal temperature sensor can be selected (the
ADC_CTL_TS bit). Additionally, this step can be defined as the last in the sequence (the
42 February 07, 2014
Analog to Digital Converter (ADC)
ADC_CTL_END bit) and it can be configured to cause an interrupt when the step is complete
(the ADC_CTL_IE bit). If the digital comparators are present on the device, this step may also
be configured to send the ADC sample to the selected comparator using ADC_CTL_CMP0
through ADC_CTL_CMP7. The configuration is used by the ADC at the appropriate time when
the trigger for this sequence occurs.
Note:
If the Digital Comparator is present and enabled using the ADC_CTL_CMP0 through
ADC_CTL_CMP7 selects, the ADC sample is NOT written into the ADC sequence data FIFO.
The ui32Step parameter determines the order in which the samples are captured by the ADC when
the trigger occurs. It can range from zero to seven for the first sample sequencer, from zero to three
for the second and third sample sequencer, and can only be zero for the fourth sample sequencer.
Differential mode only works with adjacent channel pairs (for example, 0 and 1). The channel select
must be the number of the channel pair to sample (for example, ADC_CTL_CH0 for 0 and 1, or
ADC_CTL_CH1 for 2 and 3) or undefined results are returned by the ADC. Additionally, if differential
mode is selected when the temperature sensor is being sampled, undefined results are returned
by the ADC.
It is the responsibility of the caller to ensure that a valid configuration is specified; this function does
not check the validity of the specified configuration.
Returns:
None.

  • Hello Pesala,

    The arguments can be broken down as follows

    ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS); ?

    1. The first argument is the base address of the ADC Controller which in this case is ADC0_BASE

    2. The second argument is one of the 4 sequencers to be used for the conversion in the ADC Controller

    3. The third argument is the Sequencer step. Each sequencer has multiple steps which it executes one after the other to perform an ADC Conversion. Sequencer-0 has 8 steps, Sequencer-1 and Sequencer-2 has 4 steps and Sequencer-3 has 1 step

    4. The last argument tells the source of the ADC Conversion, It can be a physical channel which is a pin on the device or the temperature sensor internal to the ADC Analog

    Regards

    Amit