Good afternoon, I am trying to do the simultaneous reading of 8 channels of ADCs every 2ms (HW Buffer - Oversample 8), I notice that I have 2 channels, these being AIN8 (PE5) and AIN9 (PE4) in my software, which in the simulations in Launchpad Ek-TM4C129XL the readings of these channels in the "ui32ADCValues[4] and ui32ADCValues[5]" one signal is interfering in the other, would that be possible in this code that I developed below? Am I doing something wrong in the configuration (setupADC) or in the access to readings (ReadingADC) of the peripheral of the ADC of this microcontroller TM4C1294NCPDT?
Setup ADC:
"...
void
setupADCs()
{
SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
GPIOPinTypeADC(
GPIO_PORTE_BASE,
GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1
| GPIO_PIN_0);
GPIOPinTypeADC(GPIO_PORTB_BASE, GPIO_PIN_4);
// ADCSequenceDisable(ADC0_BASE, 0);
// ADCSequenceDisable(ADC0_BASE, 1);
// ADCSequenceDisable(ADC0_BASE, 2);
// ADCSequenceDisable(ADC0_BASE, 3);
// ADCSequenceDisable(ADC0_BASE, 4);
// ADCSequenceDisable(ADC0_BASE, 5);
// ADCSequenceDisable(ADC0_BASE, 6);
//SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ADCHardwareOversampleConfigure(ADC0_BASE, ADC_SAMPLE_BUF_SIZE);
SysCtlDelay(10);
ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
// ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_ALWAYS, 0);
// ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 1);
// ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 2);
// ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 3);
// ADCSequenceConfigure(ADC0_BASE, 4, ADC_TRIGGER_PROCESSOR, 4);
// ADCSequenceConfigure(ADC0_BASE, 5, ADC_TRIGGER_PROCESSOR, 5);
// ADCSequenceConfigure(ADC0_BASE, 6, ADC_TRIGGER_PROCESSOR, 6);
ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0); // P. Entr. Ar
ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1); // P. Entr. O2
ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2); // Fluxo Ar
ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH3); // Fluxo O2
ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_CH8); // P. Insp
ADCSequenceStepConfigure(ADC0_BASE, 0, 5, ADC_CTL_CH9); // Cell O2
ADCSequenceStepConfigure(ADC0_BASE, 0, 6, (ADC_CTL_CH10 | ADC_CTL_IE | ADC_CTL_END)); // P. Piloto Exalação
ADCSequenceEnable(ADC0_BASE, 0);
// ADCSequenceEnable(ADC0_BASE, 1);
// ADCSequenceEnable(ADC0_BASE, 2);
// ADCSequenceEnable(ADC0_BASE, 3);
// ADCSequenceEnable(ADC0_BASE, 4);
// ADCSequenceEnable(ADC0_BASE, 5);
// ADCSequenceEnable(ADC0_BASE, 6);
ADCIntClear(ADC0_BASE, 0);
// ADCIntEnable(ADC0_BASE, 0); // Entender melhor este status?
IntEnable(INT_ADC0SS0);
// ADCIntEnable(ADC0_BASE, 0); // Entender melhor este status?
}
..."
Readind ADCs (8 Channels)
"...
void
readingADCs(CMD_INPUT *inputRead)
{
uint32_t ui32ADCValues[10]; // lendo os 7 canais ADCs
float readADC;
//uint8_t number_sample;
//number_sample = WaitAndReadADC(ui32ADCValues);
// Read the value from the ADC.
ADCIntClear(ADC0_BASE, 0);
// ADCIntClear(ADC0_BASE, 1);
// ADCIntClear(ADC0_BASE, 2);
// ADCIntClear(ADC0_BASE, 3);
// ADCIntClear(ADC0_BASE, 4);
// ADCIntClear(ADC0_BASE, 5);
// ADCIntClear(ADC0_BASE, 6);
////[TODO] Investigar o tempo de 50us para conversão muito tempo na visão do Feed (04-12-20)
ADCSequenceDataGet(ADC0_BASE, 0, ui32ADCValues);
// WaitAndReadADC(ui32ADCValues);
//----------------------------------------------------------------------------------------- LEITURA PRESSAO DE ENTRADA DE AR
// Reading ADC0 (AIR INLET PRESS SENSOR - NXP5700) and digital conversion
readADC = (3.0 * (float) ui32ADCValues[0]) / 4096.0;
inputRead->inletPressAir = (readADC - CAL_OFFSET_INLET_PRESS_AIR)
/ GAIN_INLET_PRESS_AIR;
//-------------------------------------------
//limites min e max
if (inputRead->inletPressAir < 0)
{
inputRead->inletPressAir = 0;
}
else if (inputRead->inletPressAir > 700)
{
inputRead->inletPressAir = 700;
}
//---------------------------------------------- LEITURA PRESSAO DE ENTRADA DE O2
// Reading ADC1 (O2 INLET PRESS SENSOR - NXP5700) and digital conversion
readADC = (3.0 * (float) ui32ADCValues[1]) / 4096.0;
inputRead->inletPressO2 = (readADC - CAL_OFFSET_INLET_PRESS_O2)
/ GAIN_INLET_PRESS_O2;
//limites min e max
if (inputRead->inletPressO2 < 0)
{
inputRead->inletPressO2 = 0;
}
else if (inputRead->inletPressO2 > 700)
{
inputRead->inletPressO2 = 700;
}
//----------------------------------------------------------------------------------------- LEITURA FLUXO INTERNO AR
// formula do sensor Fluxo PMF4102V - Flow Rate = [(Vout - 1 V) / 4 V] x Full Scale Flow Rate
// inputRead->flowAir = (3.3 * (float)ui32ADCValues[2]) / 4096.0;
readADC = (3.0 * (float) ui32ADCValues[2]) / 4096.0;
inputRead->flowAir = (readADC - CAL_OFFSET_FLOW_AIR) / GAIN_FLOW_AIR;
//limites min e max
if (inputRead->flowAir < 0)
{
inputRead->flowAir = 0;
}
else if (inputRead->flowAir > 150)
{
inputRead->flowAir = 150;
}
//----------------------------------------------------------------------------------------- LEITURA FLUXO INTERNO O2
// Reading ADC3 (O2 FLOW SENSOR) and digital conversion
// inputRead->flowO2 = (3.3 * (float)ui32ADCValues[3]) / 4096.0;
readADC = (3.0 * (float) ui32ADCValues[3]) / 4096.0;
inputRead->flowO2 = (readADC - CAL_OFFSET_FLOW_O2) / GAIN_FLOW_O2;
//limites min e max
if (inputRead->flowO2 < 0)
{
inputRead->flowO2 = 0;
}
else if (inputRead->flowO2 > 150)
{
inputRead->flowO2 = 150;
}
//----------------------------------------------------------------------------------------- LEITURA PRESSÃO INSPIRATÓRIA
//Reading ADC8 (Inspiratory Pressure) and digital conversion
//inputRead->inspPress = (3.3 * (float) ui32ADCValues[4]) / 4096.0;
readADC = (3.0 * (float) ui32ADCValues[4]) / 4096.0;
inputRead->inspPress = (readADC - CAL_OFFSET_PRESS_INSP) / GAIN_PRESS_INSP;
//limites min e max
if (inputRead->inspPress < 0)
{
inputRead->inspPress = 0;
}
else if (inputRead->inspPress > 140)
{
inputRead->inspPress = 140;
}
//----------------------------------------------------------------------------------------- LEITURA CÉLULA DE O2
// Reading ADC9 (Oxygen sensor) and digital conversion
//inputRead->cellO2 = (3.3 * (float) ui32ADCValues[5]) / 4096.0;
readADC = (3.0 * (float) ui32ADCValues[5]) / 4096.0;
inputRead->cellO2 = 21.0 + ((readADC - CAL_OFFSET_CELL_O2) / GAIN_CELL_O2);
//limites min e max
if (inputRead->cellO2 < 0)
{
inputRead->cellO2 = 0;
}
else if (inputRead->cellO2 > 105)
{
inputRead->cellO2 = 105;
}
//----------------------------------------------------------------------------------------- LEITURA PRESSÃO PILOTO EXALAÇÃO
// Reading ADC10 (Pilot Exhalation Pressure) and digital conversion
//inputRead->inspPress = (3.3 * (float) ui32ADCValues[6]) / 4096.0;
readADC = (3.0 * (float) ui32ADCValues[6]) / 4096.0;
inputRead->expPilotPress = (readADC - CAL_OFFSET_PRESS_PILOT_EXP)
/ GAIN_PRESS_PILOT_EXP;
ADCProcessorTrigger(ADC0_BASE, 0);
// ADCProcessorTrigger(ADC0_BASE, 1);
// ADCProcessorTrigger(ADC0_BASE, 2);
// ADCProcessorTrigger(ADC0_BASE, 3);
// ADCProcessorTrigger(ADC0_BASE, 4);
// ADCProcessorTrigger(ADC0_BASE, 5);
// ADCProcessorTrigger(ADC0_BASE, 6);
}
..."
Thank you!