void
ReadAdc(void)
{
// schedule();
uint32_t pui32ADC0Value[1];
while(1)
{
//
// Trigger the ADC conversion.
//
ADCProcessorTrigger(ADC0_BASE, 3);
//
// Wait for conversion to be completed.
//
while(!ADCIntStatus(ADC0_BASE, 3, false))
{
}
//
// Clear the ADC interrupt flag.
//
ADCIntClear(ADC0_BASE, 3);
//
// Read ADC Value.
//
ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value);
//
// Display the AIN0 (PE7) digital value on the console.
// uint32_t val=((1475 * 1023) - (2250 * pui32ADC0Value[0])) / 10230;
//
UARTprintf("%4d\r", pui32ADC0Value[0]);
//
// This function provides a means of generating a constant length
// delay. The function delay (in cycles) = 3 * parameter. Delay
// 250ms arbitrarily.
//
SysCtlDelay(SysCtlClockGet() / 12);
}
}
void
ConfigureADC0(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_4);
// *** ADC0
ADCSequenceConfigure(ADC0_BASE,3,ADC_TRIGGER_PROCESSOR,0);
ADCSequenceStepConfigure(ADC0_BASE,3,0,ADC_CTL_CH0|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE,3);
//ADCIntRegister(ADC0_BASE,3,&ADC0SS3IntHandler);
// *** GPIO
ADCIntClear(ADC0_BASE, 3);
}