Hello (( LM4F232H5QD board
First, I want to read the ADC value, and then send it to digital comparator.
Second, if the value is above the HighRef then interrupt.
A counter is set to count how many times it interrupts.
I want to use hysteris always mode, high band operation , and the region is 40 to 60 mV
There are two problems
1) How I set ulLowRef and ulHighRef
2) Where can I add interrupt and counter? When the voltage is beyond the region, it will interrupt and the counter will work.
Here's my code (GPIO port D pin6 as input)
//=============================================
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_6);
ADCSequenceConfigure(ADC1_BASE, 1, ADC_TRIGGER_COM1, 0);
ADCComparatorConfigure(ADC1_BASE, 1, ADC_COMP_TRIG_HIGH_HALWAYS);
ADCComparatorRegionSet(ADC1_BASE, 1, ulLowRef, ulHighRef);
ADCSequenceStepConfigure(ADC1_BASE, 1, 0, ADC_CTL_CH5| ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC1_BASE, 1);
ADCIntClear(ADC1_BASE, 1);
while(1) {
ADCProcessorTrigger(ADC1_BASE, 1);
while(!ADCIntStatus(ADC1_BASE,1, false));
ADCSequenceDataGet(ADC1_BASE,1, ulADC1_Value); }
//=============================================