Hello,
I'm having some problemson the ADC of TM4C1294
The ADC can not go to the interrupt, I have tested many times. I considered many codes on this forum and followed them. I also changed the sequence from 0 to 3 and ADC0 to ADC1. However, the ADC's interrupt didn't occur.
May be I could be lacked anywhere. Can anybody help me with this. Thanks so much.
In the startup file:
ADC0SS3IntHandler, // ADC Sequence 3
Here is my code:
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/adc.h"
#include "driverlib/rom.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
void ADC0SS3IntHandler(void);
// ****** Variables ******
uint32_t ADC0Value[1];
// Definitions
void
ConfigureUART(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE,GPIO_PIN_0|GPIO_PIN_1);
UARTConfigSetExpClk(UART0_BASE,16000000,115200,(UART_CONFIG_WLEN_8| UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE));
UARTStdioConfig(0,115200,16000000);
}
void systemSetup(void){
// *** Clock
SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
// *** Peripheral Enable
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlDelay(10);
// *** ADC0
ADCSequenceConfigure(ADC0_BASE,3,ADC_TRIGGER_PROCESSOR,0);
ADCSequenceStepConfigure(ADC0_BASE,3,0,ADC_CTL_CH0|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE,3);
ADCIntRegister(ADC0_BASE,3,&ADC0SS3IntHandler);
// *** GPIO
GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_3);
// *** Interrupts
IntEnable(INT_ADC0SS3);
ADCIntEnable(ADC0_BASE,3);
IntMasterEnable();
}
// Main program
int main(void) {
systemSetup();
ConfigureUART();
UARTprintf("connected");
while(1){
ADCProcessorTrigger(ADC0_BASE,3);
UARTprintf("trigger ok \n\r");
SysCtlDelay(160000);
}
}
// Interrupts
void ADC0SS3IntHandler(void){
ADCIntClear(ADC0_BASE,3);
UARTprintf("having interrupt \n\r");
ADCSequenceDataGet(ADC0_BASE,3,ADC0Value); // Get Data from ADC and store it in ADC0Value
if (ADC0Value[0] > 0) UARTprintf("having connect\n\r");
}