Hello everyone, I've got a custom board I made to be used as a test fixture and i need to read values onto the ADC for various voltage things around the board. I've been having this issue for a while now and just finally going head first to figure it out, but what keeps on happening is after I (seemingly) configured everything, the MCU goes into fault ISR after trying to read back a value from the ADCs.
Here is my startup code.
SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); while (!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE)){} SysCtlPeripheralReset(SYSCTL_PERIPH_ADC1); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); while (!SysCtlPeripheralReady(SYSCTL_PERIPH_ADC1)){} SysCtlDelay(1000); GPIOPinTypeADC(GPIO_PORTK_BASE, GPIO_PIN_1); SysCtlDelay(1000); ADCClockConfigSet(ADC1_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_EIGHTH, 30); SysCtlDelay(1000); ADCSequenceDisable(ADC1_BASE, SEQ0); SysCtlDelay(1000); ADCSequenceConfigure(ADC1_BASE, SEQ0, ADC_TRIGGER_PROCESSOR, 0); SysCtlDelay(1000); ADCSequenceStepConfigure(ADC1_BASE, SEQ0, 0, (ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH17 | ADC_CTL_SHOLD_256)); SysCtlDelay(1000); ADCSequenceEnable(ADC1_BASE, SEQ0); SysCtlDelay(1000); ADCIntEnable(ADC1_BASE, SEQ0); SysCtlDelay(1000); ADCIntClear(ADC1_BASE, SEQ0); SysCtlDelay(1000);
Here is the code that is run inside my while(1) loop (I'm trying to use the adc processor trigger mode to read values)
uint32_t *data; ADCProcessorTrigger(ADC1_BASE, SEQ0); SysCtlDelay(1000); while (!ADCIntStatus(ADC1_BASE, SEQ0, false)){} SysCtlDelay(1000); ADCIntClear(ADC1_BASE, SEQ0); SysCtlDelay(1000); if (!ADCSequenceOverflow(ADC1_BASE, SEQ0)) {ADCSequenceOverflowClear(ADC1_BASE, SEQ0);} if (!ADCSequenceUnderflow(ADC1_BASE, SEQ0)) {ADCSequenceUnderflowClear(ADC1_BASE, SEQ0);} SysCtlDelay(1000); ADCSequenceDataGet(ADC1_BASE, SEQ0, data); SysCtlDelay(1000); UARTprintf("AIN0 = %x\n", data[0]);
I thought there might be a problem with my clocking (seems to usually be the problem with these things), heres my main clock config.
g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_OSC_MAIN | SYSCTL_XTAL_25MHZ | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_240), 120000000);
And when I print g_ui32SysClock in my serial monitor I do get the value 120000000 so it seems to work properly (and I have other peripherals working on systems like I2C, SPI, and UART).
I appreciate your time and any help anyone would be willing to offer. Thanks, -Sam