Part Number: TM4C123GE6PM
Hi
I want to make a simple program using the ADC module of my Tiva TM4C123G launchpad. The idea is to configure a Timer to interrupt in a certain period of time (I want to running it at 350kHz), and trigger a conversion. I already made the code, but there must be something wrong in the ADC config. that doesn´t allow me to make more than one conversion.
any suggestions is welcome
Here is the code:
#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/adc.h"
uint32_t muestra[1];
int main(void)
{
uint32_t ui32Period;
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
ui32Period = (SysCtlClockGet()/350000) /2 ;
TimerLoadSet(TIMER1_BASE, TIMER_A, ui32Period -1);
TimerControlTrigger(TIMER1_BASE, TIMER_A, true);
// ********** ADC Config ********** //
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
// Select sequencer 3 (FIFO depth 1)
ADCSequenceDisable(ADC0_BASE, 3);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0);
//Only one step config:
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
//ADCIntClear(ADC0_BASE, 3);
//Interrupts enable
IntEnable(INT_TIMER1A);
TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
IntMasterEnable();
ADCIntEnable(ADC0_BASE, 3);
IntEnable(INT_ADC0SS3);
TimerEnable(TIMER1_BASE, TIMER_A);
while(1)
{
}
}
void Timer1IntHandler(void)
{
// Clear the timer interrupt
TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
ADCIntClear(ADC0_BASE, 3);
ADCSequenceDataGet(ADC0_BASE, 3, muestra);
}