So I am trying to set up my ADC to monitor 3 sensors and the on board temperature sensor. But I am having some serious problems.
only the on board temperature sensor is outputting any values to the ADC. We have checked the voltage at the appropriate pins (.5-1.1 V) and should be getting some kind of value but all we get is nothing. (5-7 converted value)
This is the initialization function
void InitADC(void)
{
//********************************************************************
// Initializes ADC for sensory ports for Temperature (D0), PRESSURE (D1), and RPM(D2)
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ROM_GPIOPinTypeADC(GPIO_PORTD_BASE,GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2);
ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_HALF, 1);
ROM_ADCHardwareOversampleConfigure(ADC0_BASE, 64);
ADCSequenceDisable(ADC0_BASE, 0);
ROM_ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH7);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH7);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH6);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH6);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_CH5);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 5, ADC_CTL_CH5);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 6, ADC_CTL_TS);
ROM_ADCSequenceStepConfigure(ADC0_BASE,0,7,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
ROM_ADCSequenceEnable(ADC0_BASE, 0);
}
and these are the functions gathering the data from the sequencer.
uint16_t GetEngineTemp()
{
uint16_t temp;
ROM_ADCIntClear(ADC0_BASE, 0);
ROM_ADCProcessorTrigger(ADC0_BASE, 0);
while(!ROM_ADCIntStatus(ADC0_BASE, 0, false))
{
}
ROM_ADCSequenceDataGet(ADC0_BASE, 0, ui32ADC0Value);
ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + 1)/2;
temp=ui32TempAvg;
return temp;
}
uint16_t GetPRESSURE()
{
uint16_t voltage;
ROM_ADCIntClear(ADC0_BASE, 0);
ROM_ADCProcessorTrigger(ADC0_BASE, 0);
while(!ROM_ADCIntStatus(ADC0_BASE, 0, false))
{
}
ROM_ADCSequenceDataGet(ADC0_BASE, 0, ui32ADC0Value);
ui32PressureAvg = (ui32ADC0Value[2] + ui32ADC0Value[3] + 1)/2;
voltage=ui32PressureAvg;
return voltage;
}
//**********************************************************************
//
// This function returns the converted ADC value
//
//**********************************************************************
uint16_t GetRPM()
{
uint16_t voltage;
ROM_ADCIntClear(ADC0_BASE, 0);
ROM_ADCProcessorTrigger(ADC0_BASE, 0);
while(!ROM_ADCIntStatus(ADC0_BASE, 0, false))
{
}
ROM_ADCSequenceDataGet(ADC0_BASE, 0, ui32ADC0Value);
ui32RPMAvg = (ui32ADC0Value[4] + ui32ADC0Value[5] + 1)/2;
voltage=ui32RPMAvg;
return voltage;
}
I am using Code Composer and am not getting any errors or warnings.
Thank you for your help in advance,
Josh