Hi,
I have LM4F232H5QD evaluation board and wish to use ADC digital comparator and its triggers for generation of PWM fault signal. But facing several problem. The major of all is stellaris ware does not documentation in place neither any example codes.
I have tried to make operation these ADC digital comparators but nothing fruitful came out; forget PWM part.
Anyone has got any reference documents then please share it will be helpful me.
The code which I've written is not giving me consistent results. Please see attached file. Any correction on that will also be helpful.
In this code, I expected to get interrupt from comparator 1 (when adc counts are greater than 1024) and comparator 0 (when adc counts are less than 500).
However, I have seen interrupt for comparator 1 but not for comparator 0 even though applied voltage was zero.
/*************************************************************************************************/
void ISR_ADC0_Seqnc0(void)
{
U32 ulDCIntStatus;
ulDCIntStatus = ADCComparatorIntStatus(ADC0_BASE);
ADCComparatorIntClear(ADC0_BASE, 0x0f);
} //end of ISR
void InitADC(void)
{
//ADC
GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_6);
GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_7);
//PORT E Configuration
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0);
// ADC0
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0)){;}
// Enable the first sample sequencer to capture the value of channel 0 when the processor trigger occurs.
ADCReferenceSet(ADC0_BASE, ADC_REF_INT);
ADCSequenceConfigure(ADC0_BASE, SQNC_NUM_0, ADC_TRIGGER_ALWAYS, PRIORITY_NUM);
ADCSequenceStepConfigure(ADC0_BASE, SQNC_NUM_0, STEP_0, ADC_CTL_CH3 | ADC_CTL_CMP0);
ADCSequenceStepConfigure(ADC0_BASE, SQNC_NUM_0, STEP_1, ADC_CTL_CH3 | ADC_CTL_CMP1);
ADCSequenceStepConfigure(ADC0_BASE, SQNC_NUM_0, STEP_2, ADC_CTL_CH3 | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, SQNC_NUM_0);
ADCIntRegister(ADC0_BASE, SQNC_NUM_0, ISR_ADC0_Seqnc0);
IntEnable(INT_ADC0);
ADCComparatorConfigure(ADC0_BASE, ADC_COMPARATOR_0, ADC_COMP_TRIG_LOW_HALWAYS);
ADCComparatorConfigure(ADC0_BASE, ADC_COMPARATOR_1, ADC_COMP_TRIG_HIGH_HALWAYS);
ADCComparatorRegionSet(ADC0_BASE, ADC_COMPARATOR_0, 500, 1024);
ADCComparatorRegionSet(ADC0_BASE, ADC_COMPARATOR_1, 500, 1024);
ADCComparatorReset(ADC0_BASE, ADC_COMPARATOR_0, TRUE, TRUE);
ADCComparatorReset(ADC0_BASE, ADC_COMPARATOR_1, TRUE, TRUE);
ADCComparatorIntEnable(ADC0_BASE, SQNC_NUM_0);
} //end
void main (void)
{
//clock = 50 MHz and GPIO setting are properly done (code not included here)
InitADC();
while(1)
{
}
}
/********************************************************************************************/
PS: I have made this adc module working in single ended and differential mode, in polling and interrupt mode previously, so I'm familiar with settings, but some how not able make comparator working.
Regards
Shriram
↧
Difficulties in using ADC digital comparators in LM4F232H5QD Evaluation board
↧