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.

LAUNCHXL-F28379D: ADC Interrupt Not Triggering

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Hi,

I'm trying to use the ADC module to read in an analog voltage signal from 3 analog pins (A5, C4, B4). I have used the C2000 workshop code with driverlib to configure the base ADC A, B, and C modules. However, the interrupt service routines I have written are not being executed. Could you please help me here? I'm not sure what I'm doing wrong here? The code I've for ADCinits and ISRs is as follows:

/**********************************************************************
* File: Adc.c
* Devices: TMS320F2837xD
* Author: C2000 Technical Training, Texas Instruments
**********************************************************************/

#include "SONG.h"				// Main include file


/**********************************************************************
* Function: InitAdca()
*
* Description: Initializes ADC-A on the F2837xD
**********************************************************************/
void InitAdca(void)
{

    //--- Reset the ADC.  This is good programming practice.
    SysCtl_resetPeripheral(SYSCTL_PERIPH_RES_ADCA);     // Reset ADC

    //--- Configure the ADC-A base registers
    ADC_disableConverter(ADCA_BASE);                                        // Power down ADC for configuration
    ADC_setMode(ADCA_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);    // 12-bit mode, single-ended
    ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);                           // ADC clock prescaler = CPUCLK/4
    ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);            // INT pulse generation = end of conversion

    //--- SOC0 configuration - Trigger using ePWM2-ADCSOCA; Convert channel ADCINA5; Acquisition window = 20 cycles
    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM2_SOCA, ADC_CH_ADCIN5, 20);

    //--- No ADC interrupt triggers SOC0 (TRIGSEL determined by SOC and not ADCINT1 or ADCINT2)
    ADC_setInterruptSOCTrigger(ADCA_BASE, ADC_SOC_NUMBER0, ADC_INT_SOC_TRIGGER_NONE);
    ADC_setSOCPriority(ADCA_BASE, ADC_PRI_ALL_ROUND_ROBIN);             // All SOCs handled in round-robin mode

    //--- ADCA1 interrupt configuration
    ADC_enableContinuousMode(ADCA_BASE, ADC_INT_NUMBER1);                       // Interrupt pulses regardless of flag state
    ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);        // EOC0 triggers the interrupt
    ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);                            // Enable the interrupt in the ADC

    //--- Enable ADCA1 interrupt
    Interrupt_register(INT_ADCA1, &adcA5ISR);    // Re-map ADCA1 interrupt signal to call the ISR function
    Interrupt_enable(INT_ADCA1);                 // Enable ADCA1 in PIE group 1 and enable INT1 in IER to enable PIE group 1

    //--- Finish up
    ADC_enableConverter(ADCA_BASE);             // Power up the ADC
    DEVICE_DELAY_US(1000);                      // Wait 1 ms after power-up before using the ADC

} // end InitAdca()

void InitAdcb(void)
{
    //--- Reset the ADC.  This is good programming practice.
    SysCtl_resetPeripheral(SYSCTL_PERIPH_RES_ADCB);     // Reset ADC

    //--- Configure the ADC-A base registers
    ADC_disableConverter(ADCB_BASE);                                        // Power down ADC for configuration
    ADC_setMode(ADCB_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);    // 12-bit mode, single-ended
    ADC_setPrescaler(ADCB_BASE, ADC_CLK_DIV_4_0);                           // ADC clock prescaler = CPUCLK/4
    ADC_setInterruptPulseMode(ADCB_BASE, ADC_PULSE_END_OF_CONV);            // INT pulse generation = end of conversion

    //--- SOC0 configuration - Trigger using ePWM2-ADCSOCA; Convert channel ADCINA0; Acquisition window = 20 cycles
    ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM2_SOCA, ADC_CH_ADCIN4, 20);

    //--- No ADC interrupt triggers SOC0 (TRIGSEL determined by SOC and not ADCINT1 or ADCINT2)
    ADC_setInterruptSOCTrigger(ADCB_BASE, ADC_SOC_NUMBER0, ADC_INT_SOC_TRIGGER_NONE);
    ADC_setSOCPriority(ADCB_BASE, ADC_PRI_ALL_ROUND_ROBIN);             // All SOCs handled in round-robin mode

    //--- ADCA1 interrupt configuration
    ADC_enableContinuousMode(ADCB_BASE, ADC_INT_NUMBER1);                       // Interrupt pulses regardless of flag state
    ADC_setInterruptSource(ADCB_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);        // EOC0 triggers the interrupt
    ADC_enableInterrupt(ADCB_BASE, ADC_INT_NUMBER1);                            // Enable the interrupt in the ADC

    //--- Enable ADCA1 interrupt
    Interrupt_register(INT_ADCB1, &adcB4ISR);    // Re-map ADCB1 interrupt signal to call the ISR function
    Interrupt_enable(INT_ADCB1);                 // Enable ADCB1 in PIE group 1 and enable INT1 in IER to enable PIE group 1

    //--- Finish up
    ADC_enableConverter(ADCB_BASE);             // Power up the ADC
    DEVICE_DELAY_US(1000);                      // Wait 1 ms after power-up before using the ADC

} // end InitAdcB()

void InitAdcc(void)
{
    //--- Reset the ADC.  This is good programming practice.
    SysCtl_resetPeripheral(SYSCTL_PERIPH_RES_ADCC);     // Reset ADC

    //--- Configure the ADC-C base registers
    ADC_disableConverter(ADCC_BASE);                                        // Power down ADC for configuration
    ADC_setMode(ADCC_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);    // 12-bit mode, single-ended
    ADC_setPrescaler(ADCB_BASE, ADC_CLK_DIV_4_0);                           // ADC clock prescaler = CPUCLK/4
    ADC_setInterruptPulseMode(ADCC_BASE, ADC_PULSE_END_OF_CONV);            // INT pulse generation = end of conversion

    //--- SOC0 configuration - Trigger using ePWM2-ADCSOCA; Convert channel ADCINA0; Acquisition window = 20 cycles
    ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM2_SOCA, ADC_CH_ADCIN4, 20);

    //--- No ADC interrupt triggers SOC0 (TRIGSEL determined by SOC and not ADCINT1 or ADCINT2)
    ADC_setInterruptSOCTrigger(ADCC_BASE, ADC_SOC_NUMBER0, ADC_INT_SOC_TRIGGER_NONE);
    ADC_setSOCPriority(ADCC_BASE, ADC_PRI_ALL_ROUND_ROBIN);             // All SOCs handled in round-robin mode

    //--- ADCA1 interrupt configuration
    ADC_enableContinuousMode(ADCC_BASE, ADC_INT_NUMBER1);                       // Interrupt pulses regardless of flag state
    ADC_setInterruptSource(ADCC_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);        // EOC0 triggers the interrupt
    ADC_enableInterrupt(ADCC_BASE, ADC_INT_NUMBER1);                            // Enable the interrupt in the ADC

    //--- Enable ADCA1 interrupt
    Interrupt_register(INT_ADCC1, &adcC4ISR);    // Re-map ADCB1 interrupt signal to call the ISR function
    Interrupt_enable(INT_ADCC1);                 // Enable ADCB1 in PIE group 1 and enable INT1 in IER to enable PIE group 1

    //--- Finish up
    ADC_enableConverter(ADCC_BASE);             // Power up the ADC
    DEVICE_DELAY_US(1000);                      // Wait 1 ms after power-up before using the ADC

} // end InitAdcC()

/*
 * ADCA_ISR.c
 *
 *  Created on: Apr 6, 2021
 *      Author: Kartavya Agarwal
 */

#include "SONG.h" //Main include file

interrupt void adcA5ISR(void) {
    static uint16_t *AdcABufPtr = AdcABuf;

    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);      // Must acknowledge the PIE group

    //--- Manage the ADC interrupt flag
    ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);   // Clear ADCINT1 flag

    //--- Read the ADC result
    *AdcABufPtr++ = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);    // Read the result

    //--- Brute-force the circular buffer
    if(AdcABufPtr == (AdcABuf + ADC_BUF_LEN))
    {
        AdcABufPtr = AdcABuf;                         // Rewind the pointer to beginning
    }

    v48 = (*AdcABufPtr*3)/4096;
}

interrupt void adcB4ISR(void) {
    static uint16_t *AdcBBufPtr = AdcBBuf;

    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);      // Must acknowledge the PIE group

    //--- Manage the ADC interrupt flag
    ADC_clearInterruptStatus(ADCB_BASE, ADC_INT_NUMBER1);   // Clear ADCINT1 flag

    //--- Read the ADC result
    *AdcBBufPtr++ = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER0);    // Read the result

    //--- Brute-force the circular buffer
    if(AdcBBufPtr == (AdcBBuf + ADC_BUF_LEN))
    {
        AdcBBufPtr = AdcBBuf;                         // Rewind the pointer to beginning
    }

    iout = (*AdcBBufPtr * 3.0)/4096;
}

interrupt void adcC4ISR(void) {
    static uint16_t *AdcCBufPtr = AdcCBuf;

    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);      // Must acknowledge the PIE group

    //--- Manage the ADC interrupt flag
    ADC_clearInterruptStatus(ADCC_BASE, ADC_INT_NUMBER1);   // Clear ADCINT1 flag

    //--- Read the ADC result
    *AdcCBufPtr++ = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER0);    // Read the result

    //--- Brute-force the circular buffer
    if(AdcCBufPtr == (AdcCBuf + ADC_BUF_LEN))
    {
        AdcCBufPtr = AdcCBuf;                         // Rewind the pointer to beginning
    }

    v12 = (*AdcCBufPtr * 3.0)/4096;
}

  • Hi Kartavya,

    The initialization part of ADC looks good to me. Can you help me by confirming whether the code enters the ISR? You can check by putting a breakpoint within any of the ISRs and see whether the code hits the breakpoint.

    Also, it'll be good if you can share your zipped project / code so that I can recreate the issue at my end.

    Thanks,

    Aditya

  • Hi Aditya,

    The code does not reach the ISR and the breakpoint I have been using to debug is never hit during a debug session. The zip folder for the project is attached below. Would you happen to know what I'm doing wrong here?

    SONG_cpu1.zip

  • Hi Aditya,

    Quick update, I modified InitAdca() using direct register access from the C2000Ware v3.01 example projects. InitAdcb() and InitAdcc() remain unchanged from the previous code attached above. Everything else in the project is also exactly the same and was not edited. The modified code for InitAdca() is as follows:

    void InitAdca(void)
    {
    
        //--- Reset the ADC.  This is good programming practice.
    //    SysCtl_resetPeripheral(SYSCTL_PERIPH_RES_ADCA);     // Reset ADC
    //
    //    //--- Configure the ADC-A base registers
    //    ADC_disableConverter(ADCA_BASE);                                        // Power down ADC for configuration
    //    ADC_setMode(ADCA_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);    // 12-bit mode, single-ended
    //    ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);                           // ADC clock prescaler = CPUCLK/4
    //    ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);            // INT pulse generation = end of conversion
    //
    //    //--- SOC0 configuration - Trigger using ePWM2-ADCSOCA; Convert channel ADCINA5; Acquisition window = 20 cycles
    //    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM2_SOCA, ADC_CH_ADCIN5, 20);
    //
    //    //--- No ADC interrupt triggers SOC0 (TRIGSEL determined by SOC and not ADCINT1 or ADCINT2)
    //    ADC_setInterruptSOCTrigger(ADCA_BASE, ADC_SOC_NUMBER0, ADC_INT_SOC_TRIGGER_NONE);
    //    ADC_setSOCPriority(ADCA_BASE, ADC_PRI_ALL_ROUND_ROBIN);             // All SOCs handled in round-robin mode
    //
    //    //--- ADCA1 interrupt configuration
    //    ADC_enableContinuousMode(ADCA_BASE, ADC_INT_NUMBER1);                       // Interrupt pulses regardless of flag state
    //    ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);        // EOC0 triggers the interrupt
    //    ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);                            // Enable the interrupt in the ADC
    //
    //    //--- Enable ADCA1 interrupt
    //    Interrupt_register(INT_ADCA1, &adcA5ISR);    // Re-map ADCA1 interrupt signal to call the ISR function
    //    Interrupt_enable(INT_ADCA1);                 // Enable ADCA1 in PIE group 1 and enable INT1 in IER to enable PIE group 1
    //
    //    //--- Finish up
    //    ADC_enableConverter(ADCA_BASE);             // Power up the ADC
    //    DEVICE_DELAY_US(1000);                      // Wait 1 ms after power-up before using the ADC
    
            EALLOW;
            AdcaRegs.ADCCTL2.bit.PRESCALE = 6;          // Set ADCCLK divider to /4
            AdcaRegs.ADCCTL2.bit.RESOLUTION = 0;        // 12-bit resolution
            AdcaRegs.ADCCTL2.bit.SIGNALMODE = 0;        // Single-ended channel conversions (12-bit mode only)
            AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;       // Set pulse positions to late
            AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;          // Power up the ADC
            DEVICE_DELAY_US(1000);                             // Delay for 1ms to allow ADC time to power up
            EDIS;
    
            EALLOW;
            // Assumes ePWM clock is already enabled
            EPwm2Regs.TBCTL.bit.CTRMODE = 3;            // Freeze counter
            EPwm2Regs.TBCTL.bit.HSPCLKDIV = 0;          // TBCLK pre-scaler = /1
            EPwm2Regs.TBPRD = 0x07D0;                   // Set period to 2000 counts (50kHz)
            EPwm2Regs.ETSEL.bit.SOCAEN  = 0;            // Disable SOC on A group
            EPwm2Regs.ETSEL.bit.SOCASEL = 2;            // Select SOCA on period match
            EPwm2Regs.ETSEL.bit.SOCAEN = 1;             // Enable SOCA
            EPwm2Regs.ETPS.bit.SOCAPRD = 1;             // Generate pulse on 1st event
            EDIS;
    
            EALLOW;
            AdcaRegs.ADCSOC0CTL.bit.CHSEL = 5;          // SOC0 will convert pin A0
            AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14;         // Sample window is 100 SYSCLK cycles
            AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 7;        // Trigger on ePWM2 SOCA/C
            AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0;      // End of SOC0 will set INT1 flag
            AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;        // Enable INT1 flag
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;      // Make sure INT1 flag is cleared
            EDIS;
    
            EALLOW;
            PieVectTable.ADCA1_INT = &adcA5ISR;    // Function for ADCA interrupt 1
            EDIS;
    
            // Enable PIE interrupt
            PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
    
            // Enable global interrupts and higher priority real-time debug events
            IER |= M_INT1;          // Enable group 1 interrupts
            EINT;                   // Enable Global interrupt INTM
            ERTM;                   // Enable Global real-time interrupt DBGM
    
            // Sync ePWM
            EALLOW;
            CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
            EDIS;
    
            // Start ePWM
            EPwm2Regs.TBCTL.bit.CTRMODE = 0;            // Un-freeze and enter up-count mode
    
    
    } // end InitAdca()
    

    Now all the ADC ISRs are being executed. This was confirmed using the single time graphs and breakpoints.

    Could you please explain how I can fix the driverlib code for all the ADC base module initializations? This would make the implementation a lot simpler for my application if it works.

  • Interesting! By the time I look at your code, you may also check the reference available in the driverlib folder as well.

    <C2000Ware_3_XX_00_00\driverlib\f2837xd\examples\cpu1\adc> -- You may find examples here.

  • Hi Kartavya,

    I don't see the global interrupts being enabled in your source code. Can you check by adding them after your ADC initialization in the source code?

    Also, I see that you've configured the PWM as well in the latter code that you shared. You might add that as well to the driverlib code. I am not sure whether you checked the output of EPWM2 on any GPIO pins. Request you to check that as well.

    Thanks,

    Aditya

  • HI Aditya,

    How do I enable global interrupts? I thought just enabling the interrupt will be sufficient.

    In EPwm.c in the project folder I shared with you, I have actually used driverlib to initialise EPWM2. However, I placed this code by just copying the example code.

    I will check the EPWM2 output on a pin and get back to you shortly. Will I have to change anything in my EPWM2 init function or just initialise the associated GPIO pin to output EPWM2?

  • Kartavya,

    You can enable the global interrupts using the routines 

    EINT; // Enable Global interrupt INTM
    ERTM; // Enable Global real-time interrupt DBGM

    For checking the EPWM pin on the output, just initializing the GPIO properly should do. You may take the reference from any of the EPWM driverlib example code.

    Thanks,

    Aditya

  • Got it, will add those lines in all 3 initADC functions and get back to you. Also, do you know of the Driverlib equivalents for those macros? Or are the macros the only way to enable global interrupts?

  • UPDATE:

    So enabling global interrupts now triggers my ADC ISRs, and I verified this with breakpoints.

    To test my ADC code, I applied a 1kHz 1Vpp sine wave from a function generator to all the 3 ADCIN pins. The results I'm seeing through single time graphs are highly distorted sine waves.

    To further debug, I am trying to check the EPWM2 signal because this pin is setup to trigger the ADC Start of conversion at a 100kHz sampling frequency. However I'm not seeing any pulses on GPIO 2, when I configure it as a EPWM2A pin. The InitEPWM2 initialization code and InitGpio code are as follows:

    void InitEPwm2(void)
    {
    // Must disable the clock to the ePWM modules to have all ePWM modules synchronized
    	SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
    
    //---------------------------------------------------------------------
    //--- Configure ePWM2 to trigger ADC SOCA at a 100 kHz rate
    //---------------------------------------------------------------------
    	SysCtl_resetPeripheral(SYSCTL_PERIPH_RES_EPWM2);    // Reset ePWM2
    
        EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);             // Disable the timer
        EPWM_setClockPrescaler(EPWM2_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1);   // TBCLK = EPWMCLK
        EPWM_setSyncOutPulseMode(EPWM2_BASE, EPWM_SYNC_OUT_PULSE_DISABLED);                 // Disable sync-out
        EPWM_setEmulationMode(EPWM2_BASE, EPWM_EMULATION_FREE_RUN);                         // Ignore emulation suspend
    
    	EPWM_setTimeBaseCounter(EPWM2_BASE, 0U);				        // Clear timer counter
    	EPWM_setTimeBasePeriod(EPWM2_BASE, ADC_SAMPLE_PERIOD);          // Set timer period
    	EPWM_setPhaseShift(EPWM2_BASE, 0U);                             // Set timer phase
    	EPWM_disablePhaseShiftLoad(EPWM2_BASE);                         // Disable phase load
    
    	EPWM_enableADCTrigger(EPWM2_BASE, EPWM_SOC_A);                               // Enable ADC SOCA event
    	EPWM_setADCTriggerSource(EPWM2_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_PERIOD);     // Set SOCA on PRD event
    	EPWM_setADCTriggerEventPrescale(EPWM2_BASE, EPWM_SOC_A, 1);                  // Generate SOCA on first event
    
    	EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_UP);  // Enable the timer in count up mode
    
    
    ////---------------------------------------------------------------------
    ////--- Enable the clocks to the ePWM module.
    ////--- Note: this should be done after all ePWM modules are configured
    ////--- to ensure synchronization between the ePWM modules.
    ////---------------------------------------------------------------------
    	SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);	// TBCLK to ePWM modules enabled
    
    } // end InitEPwm2()
    
    void InitGpio(void)
    {
    //--- Unlock the configuration registers for pins on all ports
    	Device_initGPIO();                              // (FILE: device.c)
    
    //--- Configure GPIO1 for LM5170 DIR
    	GPIO_setPadConfig(LM5170_DIR, GPIO_PIN_TYPE_STD);  // Push-Pull output on GPIO1
        GPIO_setPinConfig(GPIO_1_GPIO1);                   // GPIO1 = GPIO1
        GPIO_setDirectionMode(LM5170_DIR, GPIO_DIR_MODE_OUT);      // GPIO1 = output
    
    ////--- Configure GPIOXX for Master Enable for LM5170
    //    GPIO_setPadConfig(LM5170_EN, GPIO_PIN_TYPE_STD);  // Push-Pull output on GPIO2
    //    GPIO_setPinConfig(GPIO_2_GPIO2);                   // GPIO2 = GPIO2
    //    GPIO_setDirectionMode(LM5170_EN, GPIO_DIR_MODE_OUT);      // GPIOXX = output
    
        //--- Configure EPWM2A on GPIO0 for ISETD
        GPIO_setPadConfig(2, GPIO_PIN_TYPE_PULLUP);     // Enable pull-up on GPIO2
        GPIO_setPinConfig(GPIO_2_EPWM2A);               // GPIO2 = EPWM2A
    
    //--- Configure GPIO61 for Battery Source Relay Control:
        GPIO_setPadConfig(BATT_RELAY, GPIO_PIN_TYPE_STD);  // Push-Pull output on GPIO61
        GPIO_setPinConfig(GPIO_61_GPIO61);                   // GPIO61 = GPIO61
        GPIO_setDirectionMode(BATT_RELAY, GPIO_DIR_MODE_OUT);      // GPIO61 = output
    
    //--- Configure EPWM1A on GPIO0 for ISETD
        GPIO_setPadConfig(0, GPIO_PIN_TYPE_PULLUP);     // Enable pull-up on GPIO0
        GPIO_setPinConfig(GPIO_0_EPWM1A);               // GPIO0 = EPWM1A
    
    //--- Configure GPIO24 as input for ECAP1 via INPUT X-BAR (used in Lab 7)
        GPIO_setPadConfig(24, GPIO_PIN_TYPE_PULLUP);    // Enable pull-up on GPIO24
        GPIO_setPinConfig(GPIO_24_GPIO24);              // GPIO24 = GPIO24	
        GPIO_setQualificationMode(24, GPIO_QUAL_SYNC);  // Synch to SYSCLKOUT
        GPIO_setDirectionMode(24, GPIO_DIR_MODE_IN);    // GPIO24 = input
        XBAR_setInputPin(XBAR_INPUT7, 24);              // GPIO24 = ECAP1	
    
    //--- Configure GPIO34 as output (connected to LED)
        GPIO_setPadConfig(34, GPIO_PIN_TYPE_PULLUP);     // Enable pull-up on GPIO34
        GPIO_setPinConfig(GPIO_34_GPIO34);               // GPIO34 = GPIO34
        GPIO_setDirectionMode(34, GPIO_DIR_MODE_OUT);    // GPIO34 = output
        GPIO_writePin(34, 0);                            // Load output latch
    	
    //--- Configure GPIO19 as output (used in Lab 6 - pin high)
        GPIO_setPadConfig(19, GPIO_PIN_TYPE_PULLUP);     // Enable pull-up on GPIO19
        GPIO_setPinConfig(GPIO_19_GPIO19);               // GPIO19 = GPIO19
        GPIO_setDirectionMode(19, GPIO_DIR_MODE_OUT);    // GPIO19 = output
        GPIO_writePin(19, 1);                            // Load output latch
    
    //--- Configure GPIO18 as output (used in Lab 6 - pin toggle)
        GPIO_setPadConfig(18, GPIO_PIN_TYPE_PULLUP);     // Enable pull-up on GPIO18
        GPIO_setPinConfig(GPIO_18_GPIO18);               // GPIO18 = GPIO18
        GPIO_setDirectionMode(18, GPIO_DIR_MODE_OUT);    // GPIO18 = output
    
    } // end InitGpio()

    Both initEPwm2() and InitGpio() are being called in main(), but I still don't see any PWM pulses on Pin2. Could you please advice how I can resolve the distorted ADC read and PWM2 issues?

    The current version of the full project is here: 2626.SONG_cpu1.zip

  • Kartavya,

    The global interrupt macros are directly equivalent of the assembly instruction. You may open the declaration in the CCS window by right clicking on the macro to check more information.

    Regarding the ADC EPWM query, we have a same example available in the C2000Ware driverlib section. It'll be good if you can compare your code with that. I see that you've enabled the ADC trigger before configuring the ADC SOC which may not be a good way to go.

    You may refer the example adc_ex2_soc_epwm available at the location <C2000Ware_3_XX_00_00\driverlib\f2837xd\examples\cpu1\adc>.

    Thanks,

    Aditya 

  • I have already referred to the example EPWM implementation and my code doesn't differ from that.

    Also, I referred through adc_ex2_soc_epwm and perhaps the only thing that differes is the order of my enable ADC trigger and SOC setup. I will fix that and get back to you.

  • Sure, Kartavya.

    Do let me know the update.

    Thanks,

    Aditya