I am using TIVA Series TM4C129 chip in my application. Currently I am working on ADC module and I have come across Sample Sequencer which is not common as traditional single or double sampling approaches. I have few questions on this:
Why this sample sequencer? What are the advantages of this?
There is a term used “step” in this regard? What is the relation between step and sample sequencer?
Datasheet uses the term samples which is matching with “steps” (step is used in other documents like ROM user’s guide) in terms of numbers, are both the same?
To understand this I have conducted an experiment as below:
My hardware has only one analog channel connected to AIN0 (with potentiometer connected to it) and my code is as below:
static void init_adc(void) {
MAP_GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
MAP_ADCReferenceSet(ADC0_BASE, ADC_REF_INT);
MAP_ADCSequenceDisable(ADC0_BASE, SAMPLE_SEQUENCER_2);
MAP_ADCSequenceConfigure(ADC0_BASE, SAMPLE_SEQUENCER_2, ADC_TRIGGER_ALWAYS, SS_priority_3);
MAP_ADCSequenceStepConfigure(ADC0_BASE, SAMPLE_SEQUENCER_2, 0, ADC_CTL_CH1 | ADC_CTL_END);
MAP_ADCHardwareOversampleConfigure(ADC0_BASE, _NO_HARDWARE_OVERSAMPLING);
MAP_ADCSequenceEnable(ADC0_BASE, SAMPLE_SEQUENCER_2);
}
void adc_testing_task(UArg arg0, UArg arg1) {
while(1)
{
Task_sleep(10000);
test_read_adc_polling();
}
}
static void test_read_adc_polling()
{
uint32_t tempBuf[SS2_FIFO_depth];
MAP_ADCSequenceDataGet(ADC0_BASE, 2, tempBuf);
}
After running the program my tempBuf values are as below:
Potentiometer position minimum: tempBuf values : 170, 171, 171, 173
Potentiometer position middile: tempBuf values : 455, 462, 459, 458
Potentiometer position maximum: tempBuf values : 4095, 4095, 4081, 4070
My understanding: Values which is read to tempBuf corresponds to a single analog channel (AIN0) retrieved from a FIFO.
Note: Sometimes samplesRead is 5 but my tempBuf size is of 4 (still the program runs without crashing)
If I configure the 4 analog channels at once as below:
MAP_ADCSequenceStepConfigure(ADC0_BASE, SAMPLE_SEQUENCER_2, SS_2_step_0, ADC_CTL_CH0);
MAP_ADCSequenceStepConfigure(ADC0_BASE, SAMPLE_SEQUENCER_2, SS_2_step_1, ADC_CTL_CH1);
MAP_ADCSequenceStepConfigure(ADC0_BASE, SAMPLE_SEQUENCER_2, SS_2_step_2, ADC_CTL_CH2);
MAP_ADCSequenceStepConfigure(ADC0_BASE, SAMPLE_SEQUENCER_2, SS_2_step_3, ADC_CTL_CH3 | ADC_CTL_END);
How do I read the analog values of all 4 channels at once?
Do I need to have temBuf[16] (4 *4) to read four channels?
Regards
Srinivasa