Other Parts Discussed in Thread: TM4C123GH6PM, TM4C123BE6PZ
Customer find ADC module can't work normal, will jump to faultisr when debug.
I am using our Tiva launchpad to do the same test, find the same problem in KEIL (the version V4.72). but it can run normal in CCS.
If delete SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS), it can run normal and can get the ADC value.
if call SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS), will jump to faultisr.
the source code is as below.
int
main(void)
{
uint32_t ulADC0Value[4];
volatile uint32_t ulTempAvg;
volatile uint32_t ulTempValueC;
volatile uint32_t ulTempValueF;
//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPULazyStackingEnable();
//
// Set the clocking to run directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS);
ADCSequenceDisable(ADC0_BASE, 1);
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 1);
while(1)
{
ADCIntClear(ADC0_BASE, 1);
ADCProcessorTrigger(ADC0_BASE, 1);
while(!ADCIntStatus(ADC0_BASE, 1, false))
{
}
ADCSequenceDataGet(ADC0_BASE, 1, ulADC0Value);
// ulTempAvg = (ulADC0Value[0] + ulADC0Value[1] + ulADC0Value[2] + ulADC0Value[3] + 2)/4;
// ulTempValueC = (1475 - ((2475 * ulTempAvg)) / 4096)/10;
// ulTempValueF = ((ulTempValueC * 9) + 160) / 5;
}
}