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.

C2000WARE: INT_myADCA_4_ISR is not entered , why this?

Part Number: C2000WARE
Other Parts Discussed in Thread: SYSCONFIG,

Champs.

Please check my attached C file, I don't know why my ISR is never entered: INT_myADCA_4_ISR

Thanks.

//#############################################################################
//
// FILE:   lab_main.c
//
// TITLE:  C2000 Academy Lab Startup Project
//
//
// This example is a startup project for C2000 Academy lab.
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without 
// modification, are permitted provided that the following conditions 
// are met:
// 
//   Redistributions of source code must retain the above copyright 
//   notice, this list of conditions and the following disclaimer.
// 
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the 
//   documentation and/or other materials provided with the   
//   distribution.
// 
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################

//
// Included Files
//
#include "driverlib.h"
#include "device.h"

//
// Function Declarations
//
__interrupt void INT_myADCA_4_ISR(void);

//#############################################################################
//Rio Added
//
// Included Files
//
#include "board.h"
//
// Global variables and definitions
//
#define ADC_BUF_LEN         50
uint16_t DEBUG_TOGGLE = 1;    // Used for real-time mode
uint16_t AdcBuf[ADC_BUF_LEN];  // ADC buffer allocation

//#############################################################################

//Rio Below is the DAC Type 1:
//https://dev.ti.com/tirex/explore/node?node=A__AVSjOwDYHkfv9LUHQuulzA__C2000-ACADEMY__3H1LnqB__LATEST

uint16_t DacOutput;
uint16_t DacOffset;
uint16_t SINE_ENABLE = 0;
// quadrature look-up table: contains 4 quadrants of sinusoidal data points
#define SINE_PTS 25
int QuadratureTable[SINE_PTS] = {
        0x0000,         // [0]  0.0
        0x1FD4,         // [1]  14.4
        0x3DA9,         // [2]  28.8
        0x579E,         // [3]  43.2
        0x6C12,         // [4]  57.6
        0x79BB,         // [5]  72.0
        0x7FBE,         // [6]  86.4
        0x7DBA,         // [7]  100.8
        0x73D0,         // [8]  115.2
        0x629F,         // [9]  129.6
        0x4B3B,         // [10] 144.0
        0x2F1E,         // [11] 158.4
        0x100A,         // [12] 172.8
        0xEFF6,         // [13] 187.2
        0xD0E2,         // [14] 201.6
        0xB4C5,         // [15] 216.0
        0x9D61,         // [16] 230.4
        0x8C30,         // [17] 244.8
        0x8246,         // [18] 259.2
        0x8042,         // [19] 273.6
        0x8645,         // [20] 288.0
        0x93EE,         // [21] 302.4
        0xA862,         // [22] 316.8
        0xC257,         // [23] 331.2
        0xE02C          // [24] 345.6
        };

//*****************************************************************************
//Rio Added from LAB
//https://dev.ti.com/tirex/explore/node?node=A__AVSjOwDYHkfv9LUHQuulzA__C2000-ACADEMY__3H1LnqB__LATEST
//*****************************************************************************
__interrupt void INT_myADCA_4_ISR(void)
{
    static uint16_t *AdcBufPtr = AdcBuf;
    static volatile uint16_t LED_count = 0;
    // Read the ADC Result
    *AdcBufPtr++ = ADC_readResult(myADCA_RESULT_BASE, myADCA_SOC0);
    // Brute Force the circular buffer
    if (AdcBufPtr == (AdcBuf + ADC_BUF_LEN))
    {
        AdcBufPtr = AdcBuf;
    }
    // Toggle the pin
    if(DEBUG_TOGGLE == 1)
    {
        GPIO_togglePin(myGPIOToggle);
    }
    if(LED_count++ > 25000)                      // Toggle slowly to see the LED blink
    {
        GPIO_togglePin(myBoardLED0_GPIO);        // Toggle the pin
        LED_count = 0;                           // Reset the counter
    }
    //NT_myADCA_4_ISR in the sysconfig
    ADC_clearInterruptStatus(myADCA_BASE, ADC_INT_NUMBER4);
    Interrupt_clearACKGroup(INT_myADCA_4_INTERRUPT_ACK_GROUP);

    //DAC

    // Write to DAC-B to create input to ADC-A0
    static uint16_t iQuadratureTable = 0;        // Quadrature table index
    if(SINE_ENABLE == 1)
    {
        DacOutput = DacOffset + ((QuadratureTable[iQuadratureTable++] ^ 0x8000) >> 5);
    }
    else
    {
        DacOutput = DacOffset;
    }
    if(iQuadratureTable > (SINE_PTS - 1))        // Wrap the index
    {
        iQuadratureTable = 0;
    }
    DAC_setShadowValue(myDACB_BASE, DacOutput);

} // End of ADC ISR



//
// Main
//
void main(void)
{
    // Device Initialization
    Device_init();

    // Initialize GPIO and configure the GPIO pin as a push-pull output
    Device_initGPIO();
    GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
    GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);

    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    Interrupt_initModule();
    // Initialize the PIE vector table
    Interrupt_initVectorTable();
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)

    // Configure the GPIOs/ADC/PWM through SysConfig generated function found within board.c
    Board_init();

    EINT;
    ERTM;

#if 1
    // Loop Forever
    for(;;)
    {
        // Turn on LED
        GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
        // Delay for a bit.
        //DEVICE_DELAY_US(500000);
        // Turn off LED
        GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
        // Delay for a bit.
        //DEVICE_DELAY_US(500000);
    }
#endif

}

//
// End of File
//

BR Rio

  • Hi, 

    Are you configuring ADC and enabling ADC interrupts in Sysconfig? I don't see ADC configured in the C file.  Can you share the CCS project or sysconfig file?

    Best Regards

    Siddharth

  • Hi Siddharth:

    Please review my attached.

    I have 100% followed this document to experience the ePWM + ADC.

    However, here are my problems:

           #1. Set the INT_myADCA_1_ISR as breakpoint, it never be trapped.

           #2. The Graph is sometimes no show, I don't know why.

           #3.  The graph parameter is "&AdcBuf" or the AdcBuf"? I found some E2E mentioned it needs to be assigned as "&AdbBuf".

                  I have tried both, ....

    I'm using C2000Ware 5.10 + 280049LP.

    BR Rio

    //#############################################################################
    //
    // FILE:   lab_main.c
    //
    // TITLE:  C2000 Academy Lab Startup Project
    //
    //
    // This example is a startup project for C2000 Academy lab.
    //
    //#############################################################################
    //
    //
    // $Copyright:
    // Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //#############################################################################
    
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    
    //#############################################################################
    //Rio Added
    //
    // Included Files
    //
    #include "board.h"
    //
    // Global variables and definitions
    //
    #define ADC_BUF_LEN         50
    uint16_t DEBUG_TOGGLE = 1;    // Used for real-time mode
    uint16_t AdcBuf[ADC_BUF_LEN];  // ADC buffer allocation
    
    //#############################################################################
    
    //Rio Below is the DAC Type 1:
    //https://dev.ti.com/tirex/explore/node?node=A__AVSjOwDYHkfv9LUHQuulzA__C2000-ACADEMY__3H1LnqB__LATEST
    
    uint16_t DacOutput;
    uint16_t DacOffset;
    uint16_t SINE_ENABLE = 0;
    // quadrature look-up table: contains 4 quadrants of sinusoidal data points
    #define SINE_PTS 25
    int QuadratureTable[SINE_PTS] = {
            0x0000,         // [0]  0.0
            0x1FD4,         // [1]  14.4
            0x3DA9,         // [2]  28.8
            0x579E,         // [3]  43.2
            0x6C12,         // [4]  57.6
            0x79BB,         // [5]  72.0
            0x7FBE,         // [6]  86.4
            0x7DBA,         // [7]  100.8
            0x73D0,         // [8]  115.2
            0x629F,         // [9]  129.6
            0x4B3B,         // [10] 144.0
            0x2F1E,         // [11] 158.4
            0x100A,         // [12] 172.8
            0xEFF6,         // [13] 187.2
            0xD0E2,         // [14] 201.6
            0xB4C5,         // [15] 216.0
            0x9D61,         // [16] 230.4
            0x8C30,         // [17] 244.8
            0x8246,         // [18] 259.2
            0x8042,         // [19] 273.6
            0x8645,         // [20] 288.0
            0x93EE,         // [21] 302.4
            0xA862,         // [22] 316.8
            0xC257,         // [23] 331.2
            0xE02C          // [24] 345.6
            };
    
    //
    // Function Declarations
    //
    __interrupt void INT_myADCA_1_ISR(void);
    
    
    //
    // Main
    //
    void main(void)
    {
        // Device Initialization
        Device_init();
    
    #if 0
        // Initialize GPIO and configure the GPIO pin as a push-pull output
        Device_initGPIO();
        GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
        GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
    #endif
    
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        Interrupt_initModule();
        // Initialize the PIE vector table
        Interrupt_initVectorTable();
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    
        // Configure the GPIOs/ADC/PWM through SysConfig generated function found within board.c
        Board_init();
    
        EINT;
        ERTM;
    
    #if 0
        // Loop Forever
        for(;;)
        {
            // Turn on LED
            GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
            // Delay for a bit.
            SysCtl_delay(500000);
            // Turn off LED
            GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
            // Delay for a bit.
            SysCtl_delay(500000);
        }
    #else
        while(1){}
    #endif
    
    }
    //*****************************************************************************
    //Rio Added from LAB
    //https://dev.ti.com/tirex/explore/node?node=A__AVSjOwDYHkfv9LUHQuulzA__C2000-ACADEMY__3H1LnqB__LATEST
    //*****************************************************************************
    interrupt void INT_myADCA_1_ISR(void)
    
    {
        static uint16_t *AdcBufPtr = AdcBuf;
        static volatile uint16_t LED_count = 0;
        // Read the ADC Result
        *AdcBufPtr++ = ADC_readResult(myADCA_RESULT_BASE, myADCA_SOC0);
        // Brute Force the circular buffer
        if (AdcBufPtr == (AdcBuf + ADC_BUF_LEN))
        {
            AdcBufPtr = AdcBuf;
        }
        // Toggle the pin
        if(DEBUG_TOGGLE == 1)
        {
            GPIO_togglePin(myGPIOToggle);
        }
        if(LED_count++ > 25000)                      // Toggle slowly to see the LED blink
        {
            GPIO_togglePin(myBoardLEDGPIO0);        // Toggle the pin
            LED_count = 0;                           // Reset the counter
        }
    
    
        //DAC
    
        // Write to DAC-B to create input to ADC-A0
        static uint16_t iQuadratureTable = 0;        // Quadrature table index
        if(SINE_ENABLE == 1)
        {
            DacOutput = DacOffset + ((QuadratureTable[iQuadratureTable++] ^ 0x8000) >> 5);
        }
        else
        {
            DacOutput = DacOffset;
        }
        if(iQuadratureTable > (SINE_PTS - 1))        // Wrap the index
        {
            iQuadratureTable = 0;
        }
        DAC_setShadowValue(myDACB_BASE, DacOutput);
    
        //INT_myADCA_4_ISR in the sysconfig
        Interrupt_clearACKGroup(INT_myADCA_1_INTERRUPT_ACK_GROUP);
        ADC_clearInterruptStatus(myADCA_BASE, ADC_INT_NUMBER1);
    
    } // End of ADC ISR
    
    
    
    
    
    //
    // End of File
    //
    
    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/171/lab_5F00_f28004x_5F00_launchpad.syscfg

  • Hi Rio, 

    What "document" are you referring to? Do you mean the C2000 Academy ADC Lab instructions? If you follow all of the instructions and implement the correct SysConfig settings there, you should be able to implement the ADC ISR correctly. I have just run this example's solution myself and was able to hit a breakpoint set in the INT_myADCA_1_ISR() as well as view the memory browser and graph as expected. You can look at the solution I used from C2000Ware_5_01_00_00\training\device\f28004x\analog_subsystems\lab_adc for the LaunchPad (lab_adc_launchpad) and compare your project to see if there was a setting or piece of code missing/incorrect. 

    Please note that CCS doesn't save your graph settings in between debug sessions, so you will have to implement the Graph tool for each debug (i.e. go to Tools > graph > single time> adjust settings as per instructions each time you debug). If you don't reset the graph, it can show up as a blank page.

    When setting the Graph up, you should use "AdcBuf" as the start address. But when using the Memory Browser window, you should type in &AdcBuf. 

    Let me know if you are able to get the solution version from C2000Ware working.

    Best Regards,

    Allison

  • Hi Allison:

    This issue was resolved, thanks for your kind help.

    BR Rio