I have been trying to get the ADC to be read at a timed interval. I have the interrupt working for timer A to where it is going into the interrupt. The ADC isn't going into any interrupt.
#include <stdint.h> #include <stdbool.h> #include <math.h> #include "inc/tm4c123gh6pm.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/timer.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/pwm.h" #include "driverlib/pin_map.h" #include "inc/hw_gpio.h" #include "driverlib/fpu.h" #define TARGET_IS_BLIZZARD_RB1 #include "driverlib/rom.h" #define PWM_FREQUENCY 55 int main(void) { volatile uint32_t ui32Load; volatile uint32_t ui32PWMClock; volatile uint8_t ui8Adjust; ui8Adjust = 83; uint32_t ui32Period; ROM_SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); ROM_SysCtlPWMClockSet(SYSCTL_PWMDIV_64); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); ui32Period = (ROM_SysCtlClockGet() / 10) / 2; ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period -1); ROM_GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_0); ROM_GPIOPinConfigure(GPIO_PD0_M1PWM0); ROM_ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); ROM_ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS); ROM_ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS); ROM_ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS); ROM_ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_CH0|ADC_CTL_IE|ADC_CTL_END); ROM_ADCSequenceEnable(ADC0_BASE, 1); HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01; HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0; ROM_GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_DIR_MODE_IN); ROM_GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); ui32PWMClock = SysCtlClockGet() / 64; ui32Load = (ui32PWMClock / PWM_FREQUENCY) - 1; ROM_PWMGenConfigure(PWM1_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN); ROM_PWMGenPeriodSet(PWM1_BASE, PWM_GEN_0, ui32Load); ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_0, ui8Adjust * ui32Load / 1000); ROM_PWMOutputState(PWM1_BASE, PWM_OUT_0_BIT, true); ROM_PWMGenEnable(PWM1_BASE, PWM_GEN_0); ROM_IntEnable(INT_TIMER0A); ROM_IntEnable(INT_ADC0SS1); ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); ROM_TimerEnable(TIMER0_BASE, TIMER_A); ROM_IntMasterEnable(); while(1) { if(ROM_GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0x00) { ui8Adjust--; if (ui8Adjust < 36) //56 { ui8Adjust = 36; } ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_0, ui8Adjust * ui32Load / 1000); } if(ROM_GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_0)==0x00) { ui8Adjust++; if (ui8Adjust > 128) //111 { ui8Adjust = 128; } ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_0, ui8Adjust * ui32Load / 1000); } ROM_SysCtlDelay(100000); } } void Timer0IntHandler(void) { // Clear the timer interrupt ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Read the current state of the GPIO pin and // write back the opposite state if(ROM_GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2)) { ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0); } else { ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4); } } void ADC0IntHandler(void) { uint32_t ui32ADC0Value[4]; volatile uint32_t ui32TempAvg; volatile uint32_t ui32TempValueC; volatile uint32_t ui32TempValueF; ROM_ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value); ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4; ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10; ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5; ADCIntClear(ADC0_Base,1); }