Other Parts Discussed in Thread: EK-TM4C1294XL,
Tool/software: Code Composer Studio
Hello, I'm trying to use the ADC0 module on the TM4C1294XL board with PE1 as the analog input. I'm trying to use interrupts for the sampling but the interrupts aren't triggering. Could you look at my code and see what's wrong? Thank you.
main:
#include <stdbool.h> #include <stdint.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_adc.h" #include "inc/hw_types.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "inc/tm4c1294ncpdt.h" volatile static uint32_t adcResult = 0; void ADC0SS3_Handler(void) //interrupt function { adcResult = ADC0_SSFIFO3_R; //stores digital value in variable ADCIntClear(ADC0_BASE, 3); //clears interrupt flag } int main() { SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //enables clocks for ADC and GPIO SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1); //configures PE1 for analog ADC input IntDisable(INT_ADC0SS3); //disables modules for configuration ADCIntDisable(ADC0_BASE, 3); ADCSequenceDisable(ADC0_BASE, 3); ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_ALWAYS, 0); //configures ADC0 to continuously trigger ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_END |ADC_CTL_IE); //ADC calls an interrupt when conversion step is complete ADCSequenceEnable(ADC0_BASE, 3); //enables sample sequencer ADCIntClear(ADC0_BASE, 3); //enables interrupts ADCIntEnable(ADC0_BASE, 3); IntEnable(INT_ADC0SS3); IntMasterEnable(); while(1) //dead loop { {} } return 0; }
startup:
#include <stdint.h> volatile static uint32_t adcResult = 0; //***************************************************************************** // // Forward declaration of the default fault handlers. // //***************************************************************************** void ResetISR(void); static void NmiSR(void); static void FaultISR(void); static void IntDefaultHandler(void); //***************************************************************************** // // External declaration for the reset handler that is to be called when the // processor is started // //***************************************************************************** extern void _c_int00(void); //***************************************************************************** // // Linker variable that marks the top of the stack. // //***************************************************************************** extern uint32_t __STACK_TOP; //***************************************************************************** // // External declarations for the interrupt handlers used by the application. // //***************************************************************************** extern void ADC0SS3_Handler(void); //***************************************************************************** // // The vector table. Note that the proper constructs must be placed on this to // ensure that it ends up at physical address 0x0000.0000 or at the start of // the program if located at a start address other than 0. // //***************************************************************************** #pragma DATA_SECTION(g_pfnVectors, ".intvecs") void (* const g_pfnVectors[])(void) = { (void (*)(void))((uint32_t)&__STACK_TOP), // The initial stack pointer ResetISR, // The reset handler NmiSR, // The NMI handler FaultISR, // The hard fault handler IntDefaultHandler, // The MPU fault handler IntDefaultHandler, // The bus fault handler IntDefaultHandler, // The usage fault handler 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved IntDefaultHandler, // SVCall handler IntDefaultHandler, // Debug monitor handler 0, // Reserved IntDefaultHandler, // The PendSV handler IntDefaultHandler, // The SysTick handler IntDefaultHandler, // GPIO Port A IntDefaultHandler, // GPIO Port B IntDefaultHandler, // GPIO Port C IntDefaultHandler, // GPIO Port D IntDefaultHandler, // GPIO Port E IntDefaultHandler, // UART0 Rx and Tx IntDefaultHandler, // UART1 Rx and Tx IntDefaultHandler, // SSI0 Rx and Tx IntDefaultHandler, // I2C0 Master and Slave IntDefaultHandler, // PWM Fault IntDefaultHandler, // PWM Generator 0 IntDefaultHandler, // PWM Generator 1 IntDefaultHandler, // PWM Generator 2 IntDefaultHandler, // Quadrature Encoder 0 IntDefaultHandler, // ADC Sequence 0 IntDefaultHandler, // ADC Sequence 1 IntDefaultHandler, // ADC Sequence 2 ADC0SS3_Handler, // ADC Sequence 3 ...