Part Number: TM4C129XNCZAD
Hello, I have a custom board that uses TM4C129XNCZAD as the processor and I have some values that are sent to the ADC from GPIO pins. I have followed the sample code in the Peripheral Driver Library document and for some reason ADCProcessorTrigger() does not cause an interrupt to fire. Here is the code I have:
Initialization method used to initialize the ADC and the sequences, the last function maps the values read from ADC to buffers to be used in the code and send to an UI. There are more pins that go to the ADC but I didn't include that for privacy reasons.
void InitializeADC( void )
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0)){
}
*/
ADCHardwareOversampleConfigure( ADC0_BASE, 4 );
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_ADC1)){
}
ADCHardwareOversampleConfigure( ADC1_BASE, 4 );
//Enable the ADC inputs on port B.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
/* Set the ADC pins for analog input mode. */
GPIOPinTypeADC( GPIO_PORTB_BASE,
(GPIO_PIN_4 |
GPIO_PIN_5 ) );
InitializeADC0Sequence0();
InitializeADC0Sequence1();
InitializeADC1Sequence0();
InitializeADC1Sequence1();
MapCPUAnalogValues();
}
Sequence initialization for Sequence 0 of ADC 0.
//Initializes ADC 0 sequence 0 for PORT B and P ADC inputs.
static void InitializeADC0Sequence0( void )
{
//
// Disable the ADC sequence and interrupts for safe reconfiguration of
// the ADC sequences.
//
IntDisable(INT_ADC0SS0);
ADCIntDisable(ADC0_BASE, 0);
ADCSequenceDisable(ADC0_BASE, 0);
ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 2);
//
// Program the sequence.
//
ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH10); // Optical Amplifier Heater Current.
ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH11); // Seed Laser Photodiode Current.
ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH22); // 15V Voltage Monitor.
ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH23); // Exta Analog Input
ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ( ADC_CTL_END | ADC_CTL_IE ) );
//
// Re-enable the ADC sequence code.
//
ADCSequenceEnable(ADC0_BASE, 0);
ADCIntEnable(ADC0_BASE, 0);
IntEnable(INT_ADC0SS0);
}
Interrupt handler for Sequence 0 ADC 0. DataBuffer is defined somewhere else, changed name for privacy.
//Handles the interrupt for ADC 0 Sequence 0
void InterruptHandlerADC0Seq0( void )
{
ADCIntClear(ADC0_BASE, 0);
ADCSequenceDataGet(ADC0_BASE,
0,
DataBuffer);
}
ADCProcessorTrigger Call for Sequence 0 ADC 0.
if( ADCTriggerCounter == 3 )
{
ADCProcessorTrigger( ADC0_BASE, 0 );
}
I have tested the code using debug points to make sure everything runs through and all the initialization code runs. ADCProcessorTrigger() for all of the sequences also gets called but my debug points in the interrupt handlers never get called. I also tried running the sample code given in the Peripheral Driver Library with nothing else running and it did not work either (https://www.ti.com/lit/ug/spmu298e/spmu298e.pdf?ts=1644196373578&ref_url=https%253A%252F%252Fwww.google.com%252F) this code gets stuck at:
//
// Wait until the sample sequence has completed.
//
while(!ADCIntStatus(ADC0_BASE, 0, false))
{
}
Any help on why the ADC code is not working is appreciated.
Thanks for the assistance.