Part Number: TM4C1290NCPDT
Tool/software: TI C/C++ Compiler
Hi,
I want to setup the ADC to cyclic sampling, which creates an interrupt, when exceeding a limit once. What already works, is the periodic sampling and generating an Interrupt. The desired interrupt for limits, I can't get running. I cannot find the proper samples for that purpose and I think the documentation is at least "minimalistic" . If i enable the LIMIT_CHECK (see below) I get an interrupt, but this is constantly triggered and the rest of the program is disturbed by this. It seems as if the Interrupt will not be cleared. Any help or hint is welcome.
What's the difference between ADCIntEnableEx(ADC_DEVICE_BASE, ADC_INT_DCON_SS0) and ADCComparatorIntClear( ADC_DEVICE_BASE,ADC_SEQUENCE) ?
Thanks in advance
Micky
#define ADC_SEQUENCE 0
#define ADC_SEQUENCE_PRIO 0
#define ADC_DEVICE_BASE ADC0_BASE
#define SYSCTL_PERIPH_ADC_DEVICE SYSCTL_PERIPH_ADC0
#define ADC_INPUT_PIN GPIO_PIN_2
#define ADC_INPUT_PORT GPIO_PORTK_BASE
#define ADC_OVERSAMPLING 64
#define ADC_DIGITAL_COMP 0
#define ADC_VAL_LOW 20
#define ADC_VAL_HIGH 750
#define ADC_COMP_RESET 1
#define ADC_CHANNEL ADC_CTL_CH19
#define ADC_LAST_STEP 0
#define ADC_INT_SRC INT_ADC0SS0
#define TIMER_ADCSRC_100MS TIMER_A
#define TIMER_ADCSRC_10MS TIMER_B
#define ADC_SEQUENCER_LEN 8
vfnInitAdc() {
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC_DEVICE); ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL,24); GPIOPinTypeADC(ADC_INPUT_PORT, ADC_INPUT_PIN); IntDisable(ADC_INT_SRC); ADCIntDisable(ADC_DEVICE_BASE, ADC_SEQUENCE); ADCSequenceDisable(ADC_DEVICE_BASE, ADC_SEQUENCE ); ADCHardwareOversampleConfigure(ADC_DEVICE_BASE, ADC_OVERSAMPLING ); ADCSequenceConfigure(ADC_DEVICE_BASE, ADC_SEQUENCE, ADC_TRIGGER_TIMER, ADC_SEQUENCE_PRIO); #ifdef READ_VALUE ADCSequenceStepConfigure(ADC_DEVICE_BASE, ADC_SEQUENCE, ADC_LAST_STEP, ADC_CHANNEL | ADC_CTL_IE | ADC_CTL_END); #elif defined(LIMIT_CHECK) ADCSequenceStepConfigure(ADC_DEVICE_BASE, ADC_SEQUENCE, ADC_LAST_STEP, ADC_CHANNEL | ADC_CTL_CMP0 | ADC_CTL_END); #else #error "ADC Define READ_VALUE or LIMIT_CHECK " #endif ADCComparatorConfigure( ADC_DEVICE_BASE, ADC_DIGITAL_COMP, ADC_COMP_INT_HIGH_HONCE); ADCComparatorRegionSet(ADC_DEVICE_BASE, ADC_DIGITAL_COMP, ADC_VAL_LOW, ADC_VAL_HIGH); ADCComparatorReset(ADC_DEVICE_BASE, ADC_DIGITAL_COMP, ADC_COMP_RESET, ADC_COMP_RESET ); ADCIntClear(ADC_DEVICE_BASE, ADC_SEQUENCE); ADCIntClearEx(ADC_DEVICE_BASE,ADC_INT_DCON_SS0); ADCComparatorIntClear(ADC_DEVICE_BASE,ADC_SEQUENCE); ADCIntEnable(ADC_DEVICE_BASE, ADC_SEQUENCE); // //ADCIntEnableEx(ADC_DEVICE_BASE, ADC_INT_DCON_SS0); // ADCComparatorIntEnable( ADC_DEVICE_BASE,ADC_SEQUENCE); IntEnable(ADC_INT_SRC); TimerControlTrigger(TIMER_APP_BASE,TIMER_ADCSRC_10MS,true); ADCSequenceEnable(ADC_DEVICE_BASE, ADC_SEQUENCE); } volatile uint32_t uMax=0; volatile uint32_t uMin=4096; void vfnADCSeq0Handler(void) { ADCIntClearEx(ADC_DEVICE_BASE,ADC_INT_DCON_SS0); ADCIntClear(ADC_DEVICE_BASE,ADC_SEQUENCE); ADCComparatorIntClear( ADC_DEVICE_BASE,ADC_SEQUENCE); #ifdef READ_VALUE static uint32_t auADCValue[8]; ADCSequenceDataGet(ADC_DEVICE_BASE,ADC_SEQUENCE,auADCValue); // der interessante Wert ist nun in auADCValue[0] if (uMax<auADCValue[0]) uMax=auADCValue[0]; if (uMin>auADCValue[0]) uMin=auADCValue[0]; #else guLimit=1; ADCComparatorReset(ADC_DEVICE_BASE, ADC_DIGITAL_COMP, ADC_COMP_RESET, ADC_COMP_RESET ); //IntDisable(ADC_INT_SRC); #endif }