I am having some trouble getting the ADC interrupt to occur. I am using the launch pad with CCSv5.4.
When I run the program the handler for the ADC never occurs; the while loop continuously runs. I think I have called all the interrupt enable functions I need and set the interrupt setting correctly. Does anyone see the issue?
This is my addition to the startup file (startup_ccs.c):
extern void IntADC1Handler(void);
.
IntADC1Handler, // ADC Sequence 0
This is my code:
#include <stdint.h>
#include <stdbool.h>
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/pwm.h"
#include "driverlib/debug.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/adc.h"
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_pwm.h"
#include "inc/hw_types.h"
void IntADC1Handler(void);
uint32_t testValues[8] = {0,0,0,0,0,0,0,0};
int test = 0;
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|
SYSCTL_OSC_MAIN);
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
PWMGenEnable(PWM0_BASE, PWM_GEN_0);
PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN);
PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_0,PWM_INT_CNT_ZERO | PWM_TR_CNT_LOAD);
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 1024);
PWMPulseWidthSet(PWM0_BASE, PWM_GEN_0, 512);
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
GPIOPinConfigure(GPIO_PB6_M0PWM0);
PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT | PWM_OUT_0_BIT, true);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_7);
ADCSequenceConfigure(ADC0_BASE,0,ADC_TRIGGER_PWM0,0);
ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 0);
ADCIntClear(ADC0_BASE, 0);
ADCIntEnable(ADC0_BASE,0);
IntEnable(ADC_INT_SS0);
IntMasterEnable();
while(1)
{
while(!ADCIntStatus(ADC0_BASE, 0, false))
{
} //wait for ADC to finish
test = 1;
// ADCSequenceEnable(ADC0_BASE, 0);
}
}
void IntADC1Handler(void){
//
// Go into an infinite loop.
//
ADCSequenceDataGet(ADC0_BASE, 0, testValues);
ADCIntClear(ADC0_BASE, 0);
}