Other Parts Discussed in Thread: EK-TM4C123GXL
Hi,
I'm using a Tiva EK-TM4C123GXL and I can't seem to get the ADC to be triggered by the timer. I've placed a breakpoint in my ADC0IntHandler, but it never seems to make it there. The code is below. I have put ADC0IntHandler in the proper location in the startup file. Any help would be much appreciated. The code is below.
Thanks,
Kyle
#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/adc.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#define F_SAMPLE 1000
uint32_t InputBuffer[1];
void ADC0IntHandler(void);
void main(void)
{
SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER0);
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
// ***Timer Initialization***
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/F_SAMPLE);
TimerEnable(TIMER0_BASE, TIMER_A);
TimerControlTrigger(TIMER0_BASE, TIMER_A, true);
// ***ADC Initialization***
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // Enable clock to the ADC module 0
SysCtlDelay(10);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); // AIN0
IntDisable(INT_ADC0SS3);
ADCIntDisable(ADC0_BASE, 3);
ADCSequenceDisable(ADC0_BASE, 3);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE |
ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE, 3);
ADCIntEnable(ADC0_BASE, 2);
IntEnable(INT_ADC0SS3);
IntMasterEnable(); // Enable processor interrupts
while(1)
{
}
}
void ADC0IntHandler(void) {
// Clear the interrupt status flag.
ADCIntClear(ADC0_BASE, 3);
ADCSequenceDataGet(ADC0_BASE, 3, InputBuffer);
}