This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280025C: ADC start of conversion using external GPIO

Part Number: TMS320F280025C
Other Parts Discussed in Thread: C2000WARE

I want to configure an ADC channel to be triggered for start of conversion by external GPIO. I understand that I need to route a GPIO to Input X-BAR INPUT5.  I have routed pin number 74 (GPIO5) to X-BAR input 5 as below:
XBAR_setInputPin(INPUTXBAR_BASE, XBAR_INPUT5, 5);
XBAR_lockInput(INPUTXBAR_BASE, XBAR_INPUT5);

The SOC is configured to use GPIO5 as external ADC trigger source as shown below:

//Configuring SOC for ADCIN6 . It will be triggered by GPIO, ADCEXTSOC
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER8, ADC_TRIGGER_GPIO,
ADC_CH_ADCIN6, 8);

An interrupt is configured to be generated when ADC conversion is complete:
//Configuring interrupt for  conversion complete
ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER2, ADC_SOC_NUMBER8);
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER2);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER2);

Finally interrupt is enables in the main function as below:
Interrupt_enable(INT_ADCA2);

To test if the conversion is done, I have toggle an LED in the ISR. Due to some reason the SOC is not getting triggered by the external GPIO or the interrupt is not being generated. There are some other interrupts configured in the code that are working so I assume that global interrupt is enabled. I think there is no example in C2000Ware for SOC trigger by external GPIO. Please guide..

  • Hi Asad,

    You can check the adc_ex4_soc_software_sync.c example which uses the GPIO to achieve simultaneous SW triggering of all ADCs via the input X-BAR. 

    The code you've posted seems about right, so I think you'll want to test each piece to see where things are not occuring correctly.  Once you run the code, you can use the expressions window (possibly with real-time mode enabled) to examine the state of the device:

    • Check the GPIO data registers to ensure the GPIO5 data is changing state with changing input on the pin
      • (GPADAT.GPIO5)
    • Check that the X-BAR data for INPUT5 is being set
      • (XBARFLG2.INPUT5)
    • Check that SOC8 is set to pending and then converts
      • (ADCSOCFLG1.SOC8 and ADCSOCPRICTL.RRPOINTER) 
    • Check that ADCRESULT8 updates
    • Check if ADCINT2 flag is set
      • (ADCINTFLG.ADCINT2)
    • Check if interrupt flags are set in the PIE and CPU

    You can also modify the device via the expressions window to test if things are working:

    • Manually trigger an SOC8 via ADC registers SOCFRC1 to determine if an ISR occurs after SOC8 converts 
      • (see adc_ex1_soc_software.c)
    • Set GPIO5 to output mode and manually toggle GPIO5 to determine if the ADC gets triggered (ensuring that the pin is disconnected from any external driver)
      • (see adc_ex4_soc_software_sync.c example)

  • Dear Devin Cottier,
           Thankyou very much for providing troubleshooting steps. Let me work on these to resolve the issues. I will update you if the issue gets resolved or any further support is needed.

  • Dear Davin Cottier,

         with your guidelines, I have been able to fix the issue. I was not clearing the ADC interrupt flag. By adding following instruction in the ISR : ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER2); the issue has been resolved.

  • Hi Asad,

    Thanks for the update, and glad you were able to get things working!  Let us know if you run into any further difficulty.