In the following code, 8 channels are set up on sequence 0, however only the first four sequences have data--the last four are all zero.
And the same result occurs if I move the last four up to the top of the sequence.
Ran this on a TM4C123 (launchpad), with TivaWare_C_Series-2.1.2.111.
<?
int main(void) { uint32_t pui32ADC0Value[8]; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // Set up the serial console to use for displaying messages. InitConsole(); // // Clear Screen // UARTprintf("\033[2J\033[;H"); // Black backbround UARTprintf("\x1b[40m"); // // Home & set text color to blue // UARTprintf("\033[H\033[36m"); UARTprintf("**************************************************\n"); UARTprintf("** Multi-ADC Test **\n"); UARTprintf("**************************************************\n"); // // Set text color to black // UARTprintf("\n\033[37m"); // Display the setup on the console. // UARTprintf("ADC ->\n"); UARTprintf(" Type: Single Ended\n"); UARTprintf(" Samples: One\n"); UARTprintf(" Update Rate: 250ms\n"); UARTprintf(" Input Pin: AIN0/PE7\n\n"); // // The ADC0 peripheral must be enabled for use. // SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // Set clock source for ADC to PIOSC (16 MHz) divided by 1 ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_FULL, 1); // Enable Ports SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // // Select the analog ADC function for these pins. // Consult the data sheet to see which functions are allocated per pin. // TODO: change this to select the port/pin you are using. // GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_0); GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_1); GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_2); GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_3); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); // // Enable sample sequence 0 with a processor signal trigger. Sequence 0 // will do 8 samples when the processor sends a signal to start the // conversion. Each ADC module has 4 programmable sequences, sequence 0 // to sequence 3. This example is using sequence 0. // ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); // // Configure step 0-7 on sequence 0. Sample channel 0 (ADC_CTL_CH0) in // single-ended mode (default) and configure the interrupt flag // (ADC_CTL_IE) to be set when the last sample is done. Tell the ADC logic // that this is the last conversion on sequence 0 (ADC_CTL_END). Sequence // 0 has only 8 programmable steps. Sequence 1 and 2 have 4 steps, and // sequence 3 has 1 programmable step. Since we are doing 8 // conversions using sequence 0 we will configure steps 0-7. For more // information on the ADC sequences and steps, reference the datasheet. // ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH4); // PD3 ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH5); // PD2 ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH6); // PD1 ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH7); // PD1 ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_CH0); // PE3 ADCSequenceStepConfigure(ADC0_BASE, 0, 5, ADC_CTL_CH1); // PE2 ADCSequenceStepConfigure(ADC0_BASE, 0, 6, ADC_CTL_CH2); // PE1 ADCSequenceStepConfigure(ADC0_BASE, 0, 7, ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END); // PE0 // // Since sample sequence 0 is now configured, it must be enabled. // ADCSequenceEnable(ADC0_BASE, 0); // // Clear the interrupt status flag. This is done to make sure the // interrupt flag is cleared before we sample. // ADCIntClear(ADC0_BASE, 0); // // Sample AIN0 forever. Display the value on the console. // while(1) { // // Trigger the ADC conversion. // ADCProcessorTrigger(ADC0_BASE, 0); // // Wait for conversion to be completed. // while(!ADCIntStatus(ADC0_BASE, 0, false)) { } // // Clear the ADC interrupt flag. // ADCIntClear(ADC0_BASE, 0); // // Read ADC Values. // ADCSequenceDataGet(ADC0_BASE, 0, &pui32ADC0Value[0]); ADCSequenceDataGet(ADC0_BASE, 1, &pui32ADC0Value[1]); ADCSequenceDataGet(ADC0_BASE, 2, &pui32ADC0Value[2]); ADCSequenceDataGet(ADC0_BASE, 3, &pui32ADC0Value[3]); ADCSequenceDataGet(ADC0_BASE, 4, &pui32ADC0Value[4]); ADCSequenceDataGet(ADC0_BASE, 5, &pui32ADC0Value[5]); ADCSequenceDataGet(ADC0_BASE, 6, &pui32ADC0Value[6]); ADCSequenceDataGet(ADC0_BASE, 7, &pui32ADC0Value[7]); // Print Results UARTprintf("AIN0,1 = %04X %04X %04X %04X %04X %04X %04X %04X\r", pui32ADC0Value[0], pui32ADC0Value[1], pui32ADC0Value[2], pui32ADC0Value[3], pui32ADC0Value[4], pui32ADC0Value[5], pui32ADC0Value[6], pui32ADC0Value[7]); SysCtlDelay(SysCtlClockGet() / 12); } }
?>