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.

CCS/TMS320F28379D: ADC Software trigger continuous execution

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

Hi,

I am trying to run the C2000 example "adc_soc_software_cpu01" in continuous mode. I have removed the software breakpoint command "asm("   ESTOP0");" from the main loop.  I am using ADC Channel0

This is the main While loop

AdcaRegs.ADCSOCFRC1.bit.SOC0 = 1; //SOC0

//wait for ADCA0 to complete, then acknowledge flag

//
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
//
//store results
//
AdcaResult0 = AdcaResultRegs.ADCRESULT0;

Settings for ADC Software other than acquisition window is below:

EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +

AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag //1 SYSCLK cycles
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
EDIS;

I run this code but it only executes once. I want to run this code continuously. Can't figure out what wrong i am doing.

  • Hi Gerrard,

    The above code looks correct. This should run continuously. How are you determining that this code executes only once?

    Thanks
    Vasudha
  • I am using the CCS Debug Feature as shown in the picture below. . If you see Debug mode is on. For viewing the register value continuously. I have turned on the continuous refresh mode. At ADC channel 0, i have used a 10k variable resistor with a 3.3 volt from TM320F28379D. ADC runs only once not continuously.

  • //###########################################################################
    //
    // FILE:   adc_soc_software_cpu01.c
    //
    // TITLE:  ADC software triggering for F2837xD.
    //
    //! \addtogroup cpu01_example_list
    //! <h1> ADC SOC Software Force (adc_soc_software)</h1>
    //!
    //! This example converts some voltages on ADCA0  based on a software
    //! trigger.
    //!
    //! After the program runs, the memory will contain:
    //!
    //! - \b AdcaResult0 \b: a digital representation of the voltage on ADC Channel A0\n
    //!
    
    
    //
    // Included Files
    //
    #include "F28x_Project.h"
    
    //
    // Function Prototypes
    //
    void ConfigureADC(void);
    void SetupADCSoftware(void);
    
    //
    // Globals
    //
    Uint16 AdcaResult0;
    
    void main(void)
    {
        InitSysCtrl();
        InitGpio();
        //GPIO_SetupPinMux(31, GPIO_MUX_CPU1, 0);
       //  GPIO_SetupPinOptions(31, GPIO_OUTPUT,GPIO_PUSHPULL);
    
    
        DINT;
    
        InitPieCtrl();
    
        IER = 0x0000;
        IFR = 0x0000;
        InitPieVectTable();
    
        EINT;  // Enable Global interrupt INTM
        ERTM;  // Enable Global realtime interrupt DBGM
    
        ConfigureADC();
        SetupADCSoftware();
    
        while(1)
        {
            AdcaRegs.ADCSOCFRC1.bit.SOC0 = 1; //SOC0 and SOC1
    
            //
            //wait for ADCA to complete, then acknowledge flag
            //
            while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
            //
            //store results
            //
            AdcaResult0 = AdcaResultRegs.ADCRESULT0;
            //GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
            //DELAY_US(1000*1000);
    
            //        AdcaRegs.ADCSOCFRC1.bit.SOC0 = 0; //SOC0 and SOC1
    
            //
            //at this point, conversion results are stored in
            //AdcaResult0, AdcaResult1, AdcbResult0, and AdcbResult1
            //
    
            //
            //software breakpoint, hit run again to get updated conversions
            //
    //        asm("   ESTOP0");
    
        }
    }
    
    
    
    
    
    
    
    
    void ConfigureADC(void)
    {
        EALLOW;
    
        //
        //write configurations
        //
        AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
        AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
    
        AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
    
        //
        //power up the ADCs
        //
        AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
        DELAY_US(1000);
        EDIS;
    }
    
    //
    // SetupADCSoftware - Setup ADC channels and acquisition window
    //
    void SetupADCSoftware(void)
    {
        Uint16 acqps;
    
        //
        // Determine minimum acquisition window (in SYSCLKS) based on resolution
        //
        if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
        {
            acqps = 14; //75ns
        }
        else //resolution is 16-bit
        {
            acqps = 63; //320ns
        }
    
        //Select the channels to convert and end of conversion flag
        //ADCA
        EALLOW;
        AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0;  //SOC0 will convert pin A0
        AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +
    //    AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 0; //For software
        AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
        AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;   //enable INT1 flag                                       //1 SYSCLK cycles
    
     //   AdcaRegs.ADCINTSEL1N2.bit. = 1;
        AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
        EDIS;
    }
    
    //
    // End of file
    //
    

  • This is the main code file
  • Hi Gerrard,

    The below line of code is the problem. The code isn't running at all and is stuck in the while loop waiting for INT1 flag. Currently, the code is configured to set INT1 flag once SOC1 conversion is complete. Change it to zero.

    AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag

    Change to below:

    AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag

    Thanks

    Vasudha

  • Thanks a lot Vasudha