Hi,
I get very "spiky" ADC sample results using TM4C1294XL. I try using sequencer 3 and also 0 but with the same results, ADC0 , AIN9/PE4. To avoid external noise on Launchpad TM4C1294XL PE4 grounded by jumper-wire. I get results : 0,2,0,0,31, 0,0,0,0,0,0,0,10, 39, 0,0,0,0.... . I came from 8 bit word (Microchip) and I'm a bit confused. VDDA ->3.3V, GNDA -> GND , 12 bit 4096 resolution , single ended. Pls some help.
void
ConfigureADC0(void)
{
// Enable clock to ADC0.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
// Configure ADC0 Sample Sequencer 3 for processor trigger operation.
ROM_ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
// Configure ADC0 sequencer 3
ROM_ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH9 | ADC_CTL_IE | ADC_CTL_END);
// Enable the sequencer.
ROM_ADCSequenceEnable(ADC0_BASE, 3);
// Clear the interrupt bit for sequencer 3 to make sure it is not set
// before the first sample is taken.
ROM_ADCIntClear(ADC0_BASE, 3);
}
void
WaitAndReadADC(void)
{
uint32_t pui32ADC0Value[1];
// Take a reading with the ADC.
ROM_ADCProcessorTrigger(ADC0_BASE, 3);
// Wait for the ADC to finish taking the sample
while(!ROM_ADCIntStatus(ADC0_BASE, 3, false))
{
}
// Clear the interrupt
ROM_ADCIntClear(ADC0_BASE, 3);
// Read the analog sample
ROM_ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value);
// Update
// the global variable.
g_i16MBMultiple_registers[0] = pui32ADC0Value[0];
}
int
main(void)
{
uint32_t ui32Count;
uint32_t ui32User0, ui32User1,ui32IPaddr,ui32NetMask,ui32GW,i;
uint8_t pui8MACArray[8];
uint32_t broi=0;
// Make sure the main oscillator is enabled because this is required by
// the PHY. The system must have a 25MHz crystal attached to the OSC
// pins. The SYSCTL_MOSC_HIGHFREQ parameter is used when the crystal
// frequency is 10MHz or higher.
//
SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);
// Run from the PLL at 120 MHz.
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
// Configure the device pins.
PinoutSet(true, false);
// Configure UART.
UARTStdioConfig(0, 115200, g_ui32SysClock);
// Configure SysTick for a periodic interrupt.
MAP_SysTickPeriodSet(g_ui32SysClock / SYSTICKHZ);
MAP_SysTickEnable();
MAP_SysTickIntEnable();
// Set the interrupt priorities. We set the SysTick interrupt to a higher
// priority than the Ethernet interrupt to ensure that the file system
// tick is processed if SysTick occurs while the Ethernet handler is being
// processed. This is very likely since all the TCP/IP and HTTP work is
// done in the context of the Ethernet interrupt.
MAP_IntPrioritySet(INT_EMAC0, ETHERNET_INT_PRIORITY);
MAP_IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY);
ConfigureADC0();
// Take an initial reading of the AIN9
// store in g_i16MBMultiple_registers[0]
WaitAndReadADC();
while(1)
{
WaitAndReadADC();
// Display the SysClock and AIN9 (PE4) digital value on the console.
UARTprintf("AIN9 = %4d\r", g_i16MBMultiple_registers[0]);
SysCtlDelay(SysCtlClockGet() / 12);
}
}