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.

TMS320C6655: How to assign the self-developed Interrupt Service Routine (ISR) into the ISTP register?

Part Number: TMS320C6655

Environment: DSP C6655,CCS5.5,Win11 64bit

Our objective is to run the EMAC Transmit Completion ISR when the EMAC completes the transmisson of an Ethernet frame. Since the CSL is NOT allowed to be used in my project, therefore, I have to write the code from scratch. EMAC TX INT is routed to CPU INT4, CPU INT4 is set when EMAC completes the transmission. The behavior is correct.

Next step is to request DSP jump into the ISR, I downloaded the vectors.asm from the ticket via the link: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/41441/how-to-initialize-the-interrupt-service-table and copied the modified vectors.asm into my project folder. Please see the code below.

vectors.asm:


.ref _c_int00
.ref _EAMC_TX_Complete

.sect "vectors"

; tell assembler not to use 16-bit compact instructions
; or else the vectors will not reside properly in memory
; (applies to entire section in which it is contained)
.nocmp

RESET_RST:
mvkl .S2 _c_int00, B0
mvkh .S2 _c_int00, B0
B .S2 B0
NOP
NOP
NOP
NOP
NOP
NMI_RST:
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP

RESV1:
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP

RESV2:
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP

INT4:
stw b0,*b15--[2]                                   ; temp save b0 on stack
mvkl _EAMC_TX_Complete,b0          ; load destination address to b0
mvkh _EAMC_TX_Complete,b0
b b0                                                     ; start branch to destination
ldw *++b15[2],b0                                 ; restore b0 register
nop 2                                                   ; fill 2 of b0 restore delay slots
nop                                                      ; fill delay slot, pad packet
nop                                                       ; fill delay slot, pad packet

The EAMC_TX_Complete is the ISR and is declared as interrupt void EAMC_TX_Complete(void). The EAMC_TX_Complete function resides in another C source file, not main.c

Meanwhile, the cmd file is updated to include the vectors section as shown below.

When I compliled the code, the CCS reports errors as shown below.

Questions:

  1. Is it mandatory to include the lib file called rts66xx.lib? If yes, where can I find out the correct lib file?
  2. How to address the errors in the Problems field in ccs?
  3. How to make DSP jump to the ISR once the CPU INT4 is active?

Thanks.

  • I reviewed another ticket via the link:

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/763632/omap-l138-how-to-hook-an-interrupt-without-ti-rtos?tisearch=e2e-sitesearch&keymatch=ISTP#

    I found out the intvecs.asm and change the ISR from interrupt void EAMC_TX_Complete(void) to interrupt void c674x_mask_int4_isr(void).

    intvecs.asm

    ;**********************************************************
    ; Global Symbols
    ;**********************************************************
    .global _intcVectorTable
    .ref __c_int00
    .global _c674x_nmi_isr
    .global _c674x_rsvd_int2_isr
    .global _c674x_rsvd_int3_isr
    .global _c674x_mask_int4_isr
    .global _c674x_mask_int5_isr
    .global _c674x_mask_int6_isr
    .global _c674x_mask_int7_isr
    .global _c674x_mask_int8_isr
    .global _c674x_mask_int9_isr
    .global _c674x_mask_int10_isr
    .global _c674x_mask_int11_isr
    .global _c674x_mask_int12_isr
    .global _c674x_mask_int13_isr
    .global _c674x_mask_int14_isr
    .global _c674x_mask_int15_isr

    ;**********************************************************
    ; Interrupt Fetch Packet
    ;**********************************************************
    VEC_ENTRY .macro addr
    STW B0,*--B15
    MVKL addr,B0
    MVKH addr,B0
    B B0
    LDW *B15++,B0
    NOP 2
    NOP
    NOP
    .endm

    ;**********************************************************
    ; Interrupt Vector Table
    ;**********************************************************
    .align 1024
    _intcVectorTable:
    VEC_ENTRY __c_int00
    VEC_ENTRY _c674x_nmi_isr
    VEC_ENTRY _c674x_rsvd_int2_isr
    VEC_ENTRY _c674x_rsvd_int3_isr
    VEC_ENTRY _c674x_mask_int4_isr
    VEC_ENTRY _c674x_mask_int5_isr
    VEC_ENTRY _c674x_mask_int6_isr
    VEC_ENTRY _c674x_mask_int7_isr
    VEC_ENTRY _c674x_mask_int8_isr
    VEC_ENTRY _c674x_mask_int9_isr
    VEC_ENTRY _c674x_mask_int10_isr
    VEC_ENTRY _c674x_mask_int11_isr
    VEC_ENTRY _c674x_mask_int12_isr
    VEC_ENTRY _c674x_mask_int13_isr
    VEC_ENTRY _c674x_mask_int14_isr
    VEC_ENTRY _c674x_mask_int15_isr

    The complier does not report any error, but I do not think the ISR is executed even the CPU INT 4 occurs (bit 4 is set in IFR)

    Questions:

    1. What else conditions should be enabled to execute the ISR? 

    Thanks.

  •  ,

    NIMU EMAC example is a working example readily available as a part of Processor SDK 6.3.

    You can make use of the sample example directly. No need to write from Scratch.

    Please visit this FAQ for more information:

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1107360/faq-tms320c6657-nimu-emac-example-for-c665x-processor-from-ti-rtos-sdk

    Please refer to this sample project too on EMAC: - " EMAC_evmc6657_C66Loopback_testProject"

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1080748/faq-tms320c6657-quick-start-guide-c6657-and-c6657-evm/4000140#4000140

    --

    Your Questions:

    1. Is it mandatory to include the lib file called rts66xx.lib? If yes, where can I find out the correct lib file?
    2. How to address the errors in the Problems field in ccs?
    3. How to make DSP jump to the ISR once the CPU INT4 is active?

    Answers : 

    1. It depends upon your software design

    2. The ccs errors will be descriptive enough to correct the errors.

    3. Please refer to the appropriate demo examples of the SDK packages. ( Software packages offered by Ti - That is Processor SDK 6.3, the latest one )

    Regards

    Shankari G

  • Thanks for your feedback.

    However, I still need to understand the rationale of the TI DSP Interrupt processing.

    I successfully generated a EMACTX system event whose number is 94 because bit 30 in the event flag register2 is set. (Address of event flag register2 is 0x01800 0008)

    Per the Interrupt Controller Diagram, the system events could be feed into DSP INT[4:15] via the interrupt selector. (I disabled the Event Combner by setting the event mask register all 1s.)

    Therefore, I set the INTSEL4 field in the INTMUX1 register to 94 to set up the link b/w system event 94 and DSP INT4. I enable the INT4 by setting Interrupt enable register (IER) to 0x13 and GIE=1 in Control Status Register (CSR).

    Issue:

    The bit 4 is not set in Interrupt flag register(IFR) in the control register.

    Would you please kindly help me figure out the root cause why INT4 is not set in Interrupt flag register? Or the above  understanding regarding Interrupt Controller is wrong?

    Thanks.

  •  ,

    Let me have a look and get back.

    Regards

    Shankari G

  • Hello Shankari,

    I wanna skip over the IFR issue and move forward to have an Interrupt Service Routine for INT4.

    I copied the intvecs.asm into my project folder, and copied the Intc_Init() from pdk_c665x_2_0_16\packages\ti\csl\arch\c67x\sr\interrupt.c. 

     void Intc_Init (void)
    {
        unsigned int step = 0;
    
        /* Set ISRs to default "do-nothing" routine */
        while(step != C674X_INT_COUNT)
            c674xISRtbl[step++] = IntDefaultHandler;
    
        /* Set interrupt service table pointer to the vector table */
        ISTP = (unsigned int)intcVectorTable;
    
        /* Clear pending CPU maskable interrupts (if any) */
        ICR = 0xFFF0;
    
        /* Enable NMIE bit to allow CPU maskable interrupts */
        IER = (1 << C674X_NMI);
    }

    The complier reports the error about the unresolved symbol intcVectorTable which is defined in intvecs.asm.

    Description	Resource	Path	Location	Type
    <a href="file:/C:/ti/ccsv5/tools/compiler/dmed/HTML/10234.html">#10234-D</a>  unresolved symbols remain	LEDTest		 	C/C++ Problem
    unresolved symbol intcVectorTable, first referenced in ./Ethernet/csl_interrupt.obj	LEDTest		 	C/C++ Problem
    #10010 errors encountered during linking; "LEDTest.out" not built	LEDTest		 	C/C++ Problem
    

    In the C file, intcVectorTable is declared as:

    extern void intcVectorTable (void);

    I did a lot of search but failed to address this issue. Would you please kindly help provide some hints?

    Thanks.

  • Hello Shankari,

    I wanna skip over the IFR issue and move forward to have an Interrupt Service Routine for INT4.

    I copied the intvecs.asm into my project folder, and copied the Intc_Init() from pdk_c665x_2_0_16\packages\ti\csl\arch\c67x\sr\interrupt.c. 

     void Intc_Init (void)
    {
        unsigned int step = 0;
    
        /* Set ISRs to default "do-nothing" routine */
        while(step != C674X_INT_COUNT)
            c674xISRtbl[step++] = IntDefaultHandler;
    
        /* Set interrupt service table pointer to the vector table */
        ISTP = (unsigned int)intcVectorTable;
    
        /* Clear pending CPU maskable interrupts (if any) */
        ICR = 0xFFF0;
    
        /* Enable NMIE bit to allow CPU maskable interrupts */
        IER = (1 << C674X_NMI);
    }

    The complier reports the error about the unresolved symbol intcVectorTable which is defined in intvecs.asm.

    Description	Resource	Path	Location	Type
    <a href="file:/C:/ti/ccsv5/tools/compiler/dmed/HTML/10234.html">#10234-D</a>  unresolved symbols remain	LEDTest		 	C/C++ Problem
    unresolved symbol intcVectorTable, first referenced in ./Ethernet/csl_interrupt.obj	LEDTest		 	C/C++ Problem
    #10010 errors encountered during linking; "LEDTest.out" not built	LEDTest		 	C/C++ Problem
    

    In the C file, intcVectorTable is declared as:

    extern void intcVectorTable (void);

    I did some investigation but failed to address this issue. What else is needed to reference the intcVectorTable in intvecs.asm?Would you please kindly help provide some hints?

    Thanks.

  • Chunhua Ni,

    It is always good to start with some reference to test the INTC.

    ----

    I could find some sample code to test the INTC. 

    ------

    Package name : Processor SDK 6.3 : - PROCESSOR-SDK-RTOS-C665x 06_03_00_106
    http://software-dl.ti.com/processor-sdk-rtos/esd/C665x/latest/index_FDS.html

    Location of the test code after the installing the package: C:\ti\pdk_c665x_2_0_16\packages\ti\csl\example\cpintc\cpintc_test.c

    ---

    /**
     *   @file  cpintc_test.c
     *
     *   @brief   
     *      This is the Example test code for the CPINTC Functional layer. The code 
     *      also utilizes the INTC CSL functional layer to determine that routing 
     *      of system interrupts to the GEM cores is done properly.
     *
     *  \par
     *  NOTE:
     *      (C) Copyright 2009 Texas Instruments, Inc.
     * 
     *  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.
     *
    */
    
    #include <stdio.h>
    #include <ti/csl/src/intc/csl_intc.h>
    #include <ti/csl/tistdtypes.h>
    #include <ti/csl/csl_cpIntcAux.h>
    
    /**********************************************************************
     ************************** Local Definitions *************************
     **********************************************************************/
    
    /* Limit Defintions: Maximum number of system interrupts and channels */
    #define MAX_NUM_SYSTEM_INTERRUPTS   200
    #define MAX_NUM_CHANNELS            12
    
    /**********************************************************************
     ************************** Global Variables **************************
     **********************************************************************/
    
    /* Intc variable declarartion */
    CSL_CPINTC_Handle           hnd;
    CSL_IntcContext             intcContext; 
    CSL_IntcEventHandlerRecord  EventHandler[30];
    CSL_IntcObj                 intcObj;
    CSL_IntcHandle              hTest; 
    CSL_IntcGlobalEnableState   state;
    CSL_IntcEventHandlerRecord  EventRecord;
    CSL_IntcParam               vectId;
    
    /* Global Registers which display the INTC and CPINTC Memory Maps. */
    CSL_IntcRegsOvly    gIntcRegisters    = (CSL_IntcRegsOvly)CSL_CGEM0_5_REG_BASE_ADDRESS_REGS;
    CSL_CPINTC_RegsOvly gCPIntc0Registers = (CSL_CPINTC_RegsOvly)CSL_CP_INTC_0_REGS;
    CSL_CPINTC_RegsOvly gCPIntc1Registers = (CSL_CPINTC_RegsOvly)CSL_CP_INTC_1_REGS;
    
    /* This is an array which keeps track of total number of interrupts received 
     * per system interrupt. */
    volatile Int32 InterruptReceived[MAX_NUM_SYSTEM_INTERRUPTS];
    
    /* This is a global counter which keeps track of the errors. */
    volatile Int32 InterruptErrorCounter = 0;
    
    /**********************************************************************
     ************************ CPINTC TEST FUNCTIONS ***********************
     **********************************************************************/
    
    /**
     *  @b Description
     *  @n  
     *      This is the TEST ISR Handler which has been installed.
     *      This simply increments a global variable which counts
     *      the number of interrupts which have been received.
     *
     *  @retval
     *      Not Applicable.
     */
    static void test_isr_handler (void* handle)
    {
        Uint32  rawStatus;
        Uint32  sysIntr = 0;
        
        /* Get the RAW status register we read only register 0 as we are interested 
         * only in System Interrupts 0-31. */
        CSL_CPINTC_getRawInterruptStatus(hnd, 0, &rawStatus);
        if (rawStatus != 0)
        {
            /* There are interrupts between 0-31 pending. */
            while (rawStatus != 0)
            {
                /* Check if the interrupt is pending or not? */
                if (rawStatus & 0x1)
                {
                    /* Interrupt is pending... Record it */
                    InterruptReceived[sysIntr]++;
    
                    /* Clear the pending system interrupt. */
                    CSL_CPINTC_clearSysInterrupt(hnd, sysIntr);                
                }
    
                /* Goto the next bit. */
                rawStatus = rawStatus >> 1;
                sysIntr++;
            }
        }
    }
    
    /**
     *  @b Description
     *  @n
     *      This test case does the following:-
     *       - Enables System Interrupt 3
     *       - Enable all Host Interrupts
     *       - Generates 20 system interrupts.
     *      Test Case passes if all 20 system interrupts were detected
     *      else the test case fails. 
     *
     *  @retval
     *      Success     -   0
     *  @retval
     *      Error       -   <0 
     */
    static Int32 test_working_sys_interrupts (void)
    {
        Uint16  index;
    
        printf ("Debug: Testing Multiple System Interrupts...\n");
        
        /* Ensure the system interrupts are enabled. */
        CSL_CPINTC_enableSysInterrupt (hnd, 3);
        
        /* Ensure that the host interrupts are enabled. */
        CSL_CPINTC_enableHostInterrupt (hnd, 3);
        CSL_CPINTC_enableAllHostInterrupt(hnd);
        
        /* Reset the global counters. */
        for (index = 0; index < MAX_NUM_SYSTEM_INTERRUPTS; index++)  
            InterruptReceived[index] = 0;
        InterruptErrorCounter = 0;
        
        /* Generate the system interrupts */    
        for (index = 0; index < 20; index++)
        {
        	int counter;
            ((CSL_CPINTC_RegsOvly)CSL_CP_INTC_0_REGS)->STATUS_SET_INDEX_REG = 3;
            for (counter = 0; counter < 50; counter++) 
            asm(" nop 5");
        }
        
        /* Spin around till all the interrupt are detected. */
        while (InterruptReceived[3] != 20);
    
        /* Check if there were any errors. */
        if (InterruptErrorCounter != 0)
            return -1;        
        
        /* The test case has passed. */
        return 0;
    }
    
    /**
     *  @b Description
     *  @n
     *      This test case does the following:-
     *       - Disables System Interrupt 3
     *       - Enables all Host Interrupts
     *       - Generates system interrupts 3
     *      Test Case passes if the ISR has not been invoked else the
     *      test fails.  
     *
     *  @retval
     *      Success     -   0
     *  @retval
     *      Error       -   <0 
     */
    static Int32 test_disable_sys_interrupt (void)
    {
        Uint16  index;
    
        printf ("Debug: Testing Disable System Interrupt...\n");
        
        /* Disable system interrupt 3 */
        CSL_CPINTC_disableSysInterrupt (hnd, 3);
        
        /* Ensure that the host interrupts are enabled. */
        CSL_CPINTC_enableHostInterrupt (hnd, 3);
        CSL_CPINTC_enableAllHostInterrupt(hnd);    
        
        /* Reset the global counters. */
        for (index = 0; index < MAX_NUM_SYSTEM_INTERRUPTS; index++)  
            InterruptReceived[index] = 0;
        InterruptErrorCounter = 0;
          
        /* Generate system interrupt 3 */    
        ((CSL_CPINTC_RegsOvly)CSL_CP_INTC_0_REGS)->STATUS_SET_INDEX_REG = 3;
        
        /* Loop around for some time; delay */    
        for (index = 0; index < 0xFFF; index++);
        
        /* Ensure that there the Interrupt Received counter has not gone up. */
        if (InterruptReceived[3] != 0)
            return -1;
        
        /* Check if there were any errors. */
        if (InterruptErrorCounter != 0)
            return -1;        
            
        /* Test Case has passed. */
        return 0;
    }
    
    /**
     *  @b Description
     *  @n
     *      This test case does the following:-
     *       - Enables System Interrupt 3
     *       - Disables all Host Interrupts
     *       - Enables Host Interrupt 3
     *       - Generates system interrupts 3
     *      Test Case passes if the ISR has not been invoked else the
     *      test fails.  
     *
     *  @retval
     *      Success     -   0
     *  @retval
     *      Error       -   <0 
     */
    static Int32 test_disable_all_host_interrupt (void)
    {
        Uint16  index;
    
        printf ("Debug: Testing Disable All Host Interrupt...\n");
        
        /* Enable system interrupt 3 */
        CSL_CPINTC_enableSysInterrupt (hnd, 3);
        
        /* Ensure that the host interrupts is individually enabled. */
        CSL_CPINTC_enableHostInterrupt (hnd, 3);
        
        /* Ensure that the global host interrupts are disabled. */
        CSL_CPINTC_disableAllHostInterrupt(hnd);    
            
        /* Reset the global counters. */
        for (index = 0; index < MAX_NUM_SYSTEM_INTERRUPTS; index++)  
            InterruptReceived[index] = 0;
        InterruptErrorCounter = 0;
            
        /* Generate system interrupt 3 */
        ((CSL_CPINTC_RegsOvly)CSL_CP_INTC_0_REGS)->STATUS_SET_INDEX_REG = 3;
        
        /* Loop around for some time; delay */    
        for (index = 0; index < 0xFFF; index++);
        
        /* Ensure that there the Interrupt Received counter has not gone up. */
        if (InterruptReceived[3] != 0)
            return -1;
            
        /* Check if there were any errors. */
        if (InterruptErrorCounter != 0)
            return -1;        
            
        /* Test Case has passed. */
        return 0;
    }
    
    /**
     *  @b Description
     *  @n
     *      This test case does the following:-
     *       - Enables System Interrupt 3
     *       - Enables all Host Interrupts
     *       - Enables Host Interrupt 3
     *       - Generates system interrupts 4
     *      Test Case passes if the ISR has not been invoked else the
     *      test fails.  
     *
     *  @retval
     *      Success     -   0
     *  @retval
     *      Error       -   <0 
     */
    static Int32 test_spurious_sys_interrupt (void)
    {
        Uint16  index;
    
        printf ("Debug: Testing spurious system Interrupt...\n");
        
        /* Enable system interrupt 3 */
        CSL_CPINTC_enableSysInterrupt (hnd, 3);
        
        /* Ensure that all the global host interrupts are enabled. */
        CSL_CPINTC_enableAllHostInterrupt(hnd);        
        
        /* Ensure that the host interrupts is individually disabled. */
        CSL_CPINTC_enableHostInterrupt (hnd, 3);
                
        /* Reset the global counters. */
        for (index = 0; index < MAX_NUM_SYSTEM_INTERRUPTS; index++)  
            InterruptReceived[index] = 0;
        InterruptErrorCounter = 0;
            
        /* Generate system interrupt 4 */
        ((CSL_CPINTC_RegsOvly)CSL_CP_INTC_0_REGS)->STATUS_SET_INDEX_REG = 4;
        
        /* Loop around for some time; delay */    
        for (index = 0; index < 0xFFF; index++);
        
        /* Ensure that there the Interrupt Received counter has not gone up. */
        if (InterruptReceived[4] != 0)
            return -1;
            
        /* Check if there were any errors. */
        if (InterruptErrorCounter != 0)
            return -1;
            
        /* Test Case has passed. */
        return 0;    
    }
    
    /**
     *  @b Description
     *  @n
     *      This test case does the following:-
     *       - Enables System Interrupt 3
     *       - Enables all Host Interrupts
     *       - Disables Host Interrupt 3
     *       - Generates system interrupts 3
     *      Test Case passes if the ISR has not been invoked else the
     *      test fails.  
     *
     *  @retval
     *      Success     -   0
     *  @retval
     *      Error       -   <0 
     */
    static Int32 test_disable_host_interrupt (void)
    {
        Uint16  index;
    
        printf ("Debug: Testing disable host Interrupt...\n");
        
        /* Enable system interrupt 3 */
        CSL_CPINTC_enableSysInterrupt (hnd, 3);
        
        /* Ensure that all the global host interrupts are enabled. */
        CSL_CPINTC_enableAllHostInterrupt(hnd);        
        
        /* Ensure that the host interrupts is individually disabled. */
        CSL_CPINTC_disableHostInterrupt (hnd, 3);
                
        /* Reset the global counters. */
        for (index = 0; index < MAX_NUM_SYSTEM_INTERRUPTS; index++)  
            InterruptReceived[index] = 0;
        InterruptErrorCounter = 0;
            
        /* Generate system interrupt 3 */
        ((CSL_CPINTC_RegsOvly)CSL_CP_INTC_0_REGS)->STATUS_SET_INDEX_REG = 3;
        
        /* Loop around for some time; delay */    
        for (index = 0; index < 0xFFF; index++);
        
        /* Ensure that there the Interrupt Received counter has not gone up. */
        if (InterruptReceived[3] != 0)
            return -1;
            
        /* Check if there were any errors. */
        if (InterruptErrorCounter != 0)
            return -1;
            
        /* Test Case has passed. */
        return 0;    
    }
    
    /**
     *  @b Description
     *  @n  
     *      Entry point for the test code.
     *
     *  @retval
     *      Not Applicable.
     */
    void main (void)
    {
        Uint32  rawStatus;
        Uint16  index;
    
        printf ("**************************************************\n");
        printf ("****************** CPINTC Testing ****************\n");
        printf ("**************************************************\n");
    
        /************************************************
         *************** INTC Configuration ************* 
         ************************************************/
        
        printf ("Debug: GEM-INTC Configuration...\n");
        
        /* INTC module initialization */
        intcContext.eventhandlerRecord = EventHandler;
        intcContext.numEvtEntries      = 10;
        if (CSL_intcInit(&intcContext) != CSL_SOK) 
        {
            printf("Error: GEM-INTC initialization failed\n");
            return;
        }    
        
        /* Enable NMIs */
        if (CSL_intcGlobalNmiEnable() != CSL_SOK) 
        {
            printf("Error: GEM-INTC global NMI enable failed\n");
            return;
        }
     
        /* Enable global interrupts */
        if (CSL_intcGlobalEnable(&state) != CSL_SOK) 
        {
            printf ("Error: GEM-INTC global enable failed\n");
            return;
        }
    
        /* Open the INTC Module for Vector ID: 4 and Event ID: 63 (C6678) 59 (C6670) 
         * 	Refer to the interrupt architecture and mapping document for the Event ID  (INTC0_OUT3)*/
        vectId = CSL_INTC_VECTID_4;
        hTest = CSL_intcOpen (&intcObj, 63, &vectId , NULL);
        if (hTest == NULL) 
        {
            printf("Error: GEM-INTC Open failed\n");
            return;
        }
        
        /* Register an call-back handler which is invoked when the event occurs. */
        EventRecord.handler = &test_isr_handler;
        EventRecord.arg = 0;
        if (CSL_intcPlugEventHandler(hTest,&EventRecord) != CSL_SOK) 
        {
            printf("Error: GEM-INTC Plug event handler failed\n");
            return;
        }
        
        /* Enabling the events. */
        if (CSL_intcHwControl(hTest,CSL_INTC_CMD_EVTENABLE, NULL) != CSL_SOK) 
        {
            printf("Error: GEM-INTC CSL_INTC_CMD_EVTENABLE command failed\n");
            return;
        }
    
        printf ("Debug: GEM-INTC Configuration Completed\n");
     
        /**************************************************
         ************* CPINTC-0 Configuration ************* 
         **************************************************/
    
        printf ("Debug: CPINTC-0 Configuration...\n");
         
        /* Open the handle to the CPINT Instance */
        hnd = CSL_CPINTC_open(0);
        if (hnd == 0)
        {
            printf ("Error: Unable to open CPINTC-0\n");
            return;       
        }
        
        /* Disable all host interrupts. */
        CSL_CPINTC_disableAllHostInterrupt(hnd);
        
        /* Configure no nesting support in the CPINTC Module. */
        CSL_CPINTC_setNestingMode (hnd, CPINTC_NO_NESTING);
    
       	/* We now map System Interrupt 0 - 3 to channel 3 */
      	CSL_CPINTC_mapSystemIntrToChannel (hnd, 0 , 2);
       	CSL_CPINTC_mapSystemIntrToChannel (hnd, 1 , 4);
      	CSL_CPINTC_mapSystemIntrToChannel (hnd, 2 , 5);
       	CSL_CPINTC_mapSystemIntrToChannel (hnd, 3 , 3);
       	
       	/* We now enable system interrupt 0 - 3 */
       	CSL_CPINTC_enableSysInterrupt (hnd, 0);
       	CSL_CPINTC_enableSysInterrupt (hnd, 1);
       	CSL_CPINTC_enableSysInterrupt (hnd, 2);
       	CSL_CPINTC_enableSysInterrupt (hnd, 3);
       	
       	/* We enable host interrupts. */
       	CSL_CPINTC_enableHostInterrupt (hnd, 3);
       	
       	/* Enable all host interrupts also. */
       	CSL_CPINTC_enableAllHostInterrupt(hnd);
       	
        printf ("Debug: CPINTC-0 Configuration Completed\n");
        
        /* Testing the CSL API. */
        printf ("***************************************\n");
        printf ("Testing the CSL API for CPINTC-0  \n");
        printf ("****************************************\n");
        
        /* Test Case: Ensure the system interrupts are being generated and the 
         * registered ISR is invoked. */    
        if (test_working_sys_interrupts() < 0)
            printf ("Error: Testing Multiple System Interrupts FAILED\n");
        else
            printf ("Debug: Testing Multiple System Interrupts Passed\n");
       
        /* Test Case: Test and ensure the if the system interrupt is disabled
         * the registered ISR is not invoked. */        
        if (test_disable_sys_interrupt() < 0)
            printf ("Error: Testing Disable System Interrupt FAILED\n");
        else
            printf ("Debug: Testing Disable System Interrupt Passed\n");
    
        /* Test Case: Ensure the if all host interrupts are disabled then 
         * the registered ISR is not invoked. */            
        if (test_disable_all_host_interrupt() < 0)
            printf ("Error: Testing Disable All Host Interrupt FAILED\n");
        else
            printf ("Debug: Testing Disable All Host Interrupt Passed\n");
        
        /* Test Case: Ensure the a spurious system interrupt does not invoke
         * the registered ISR */            
        if (test_spurious_sys_interrupt() < 0)
            printf ("Error: Testing spurious system Interrupt FAILED\n");
        else
            printf ("Debug: Testing spurious system Interrupt Passed\n");
                
        /* Test Case: Ensure the if host interrupts are disabled then the registered 
         * ISR is not invoked. */            
        if (test_disable_host_interrupt() < 0)
            printf ("Error: Testing disable host Interrupt FAILED\n");
        else
            printf ("Debug: Testing disable host Interrupt Passed\n");
    
        printf ("***************************************\n");
        printf ("CSL API testing for CPINTC-0 Completed \n");
        printf ("****************************************\n");
    
        /**************************************************
         ************* CPINTC-1 Configuration ************* 
         **************************************************/
    
        printf ("Debug: CPINTC-1 Configuration...\n");
        
        /* Open the handle to the CPINT Instance */
        hnd = CSL_CPINTC_open(1);
        if (hnd == 0)
        {
            printf ("Error: Unable to open CPINT instance 1\n");
            return;       
        }    
        
        /* Disable all host interrupts. */
        CSL_CPINTC_disableAllHostInterrupt(hnd);
            
        /* Configure no nesting support in the CPINTC Module. */
        CSL_CPINTC_setNestingMode (hnd, CPINTC_NO_NESTING);
               
        /* We now map System Interrupt 5 to channel 0 */
        CSL_CPINTC_mapSystemIntrToChannel (hnd, 5 , 0);
        
        /* We now enable system interrupt 5 */
        CSL_CPINTC_enableSysInterrupt (hnd, 5);
    
        /* We enable host interrupts. */
        CSL_CPINTC_enableHostInterrupt (hnd, 10);
    
        /* Enable all host interrupts also. */
        CSL_CPINTC_enableAllHostInterrupt(hnd);
    
        printf ("Debug: CPINTC-1 Configuration Completed\n");
    
        /* Testing the CSL API. */
        printf ("***************************************\n");
        printf ("Testing the CSL API for CPINTC-1  \n");
        printf ("****************************************\n");
    
        /* Reset the global counters. */
        for (index = 0; index < MAX_NUM_SYSTEM_INTERRUPTS; index++)  
            InterruptReceived[index] = 0;
        InterruptErrorCounter = 0;    
    
        /* Read the RAW Status register to ensure there are no interrupts pending 
         * at this time. */
        CSL_CPINTC_getRawInterruptStatus(hnd, 0, &rawStatus);
        if (rawStatus != 0)
        {
            printf ("Error: CPINTC-1 interrupt is already pending\n");
            return;
        }
    
        printf ("Debug: Testing detection of system interrupts on CPINTC-1\n");
            
        /* Generate System Interrupt 5. */
        ((CSL_CPINTC_RegsOvly)CSL_CP_INTC_1_REGS)->STATUS_SET_INDEX_REG = 5;
       
        /* We should have a pending interrupt. */
        CSL_CPINTC_getRawInterruptStatus(hnd, 0, &rawStatus);
        if (rawStatus != 0)
        {
            Uint32 sysIntr = 0;
    
            /* There are interrupts between 0-31 pending. */
            while (rawStatus != 0)
            {
                /* Check if the interrupt is pending or not? */
                if (rawStatus & 0x1)
                    InterruptReceived[sysIntr]++;
    
                /* Goto the next bit. */
                rawStatus = rawStatus >> 1;
                sysIntr++;
            }
           
            /* Make sure that we received System Interrupt 5 */ 
            if (InterruptReceived[5] != 0)
                printf ("Debug: Testing detection of system interrupts on CPINTC-1 Passed\n");
            else
                printf ("Error: Testing detection of system interrupts on CPINTC-1 FAILED\n");            
        }
        else
        {
            /* Error: No pending interrupt detected */
            printf ("Error: Testing detection of system interrupts on CPINTC-1 FAILED\n");            
        }
    
        printf ("***************************************\n");
        printf ("CSL API testing for CPINTC-1 Completed \n");
        printf ("****************************************\n");
       
        /**************************************************
         ************* CPINTC-2 Configuration ************* 
         **************************************************/
    
        printf ("Debug: CPINTC-2 Configuration...\n");
        
        /* Open the handle to the CPINT Instance */
        hnd = CSL_CPINTC_open(2);
        if (hnd == 0)
        {
            printf ("Error: Unable to open CPINT instance 2\n");
            return;       
        }    
        
        /* Disable all host interrupts. */
        CSL_CPINTC_disableAllHostInterrupt(hnd);
            
        /* Configure no nesting support in the CPINTC Module. */
        CSL_CPINTC_setNestingMode (hnd, CPINTC_NO_NESTING);
               
        /* We now map System Interrupt 20 to channel 0 */
        CSL_CPINTC_mapSystemIntrToChannel (hnd, 20 , 0);
        
        /* We now enable system interrupt 5 */
        CSL_CPINTC_enableSysInterrupt (hnd, 20);
    
        /* We enable host interrupts. */
        CSL_CPINTC_enableHostInterrupt (hnd, 10);
    
        /* Enable all host interrupts also. */
        CSL_CPINTC_enableAllHostInterrupt(hnd);
    
        printf ("Debug: CPINTC-2 Configuration Completed\n");
    
        /* Testing the CSL API. */
        printf ("***********************************\n");
        printf ("Testing the CSL API for CPINTC-2  \n");
        printf ("***********************************\n");    
       
        /* Reset the global counters. */
        for (index = 0; index < MAX_NUM_SYSTEM_INTERRUPTS; index++)  
            InterruptReceived[index] = 0;
        InterruptErrorCounter = 0;
       
        /* Read the RAW Status register to ensure there are no interrupts pending 
         * at this time. */
        CSL_CPINTC_getRawInterruptStatus(hnd, 0, &rawStatus);
        if (rawStatus != 0)
        {
            printf ("Error: CPINTC-1 interrupt is already pending\n");
            return;
        }
    
        printf ("Debug: Testing detection of system interrupts on CPINTC-2\n");
            
        /* Generate System Interrupt 20. */
        ((CSL_CPINTC_RegsOvly)CSL_CP_INTC_2_REGS)->STATUS_SET_INDEX_REG = 20;
       
        /* We should have a pending interrupt. */
        CSL_CPINTC_getRawInterruptStatus(hnd, 0, &rawStatus);
        if (rawStatus != 0)
        {
            Uint32 sysIntr = 0;
    
            /* There are interrupts between 0-31 pending. */
            while (rawStatus != 0)
            {
                /* Check if the interrupt is pending or not? */
                if (rawStatus & 0x1)
                    InterruptReceived[sysIntr]++;
    
                /* Goto the next bit. */
                rawStatus = rawStatus >> 1;
                sysIntr++;
            }
           
            /* Make sure that we received System Interrupt 20 */ 
            if (InterruptReceived[20] != 0)
                printf ("Debug: Testing detection of system interrupts on CPINTC-2 Passed\n");
            else
                printf ("Error: Testing detection of system interrupts on CPINTC-2 FAILED\n");
        }
        else
        {
            /* Error: No pending interrupt detected */
            printf ("Error: Testing detection of system interrupts on CPINTC-2 FAILED\n");
        }    
    
        /* CPINTC-2 CSL API testing has been completed. */
        printf ("***************************************\n");
        printf ("CSL API testing for CPINTC-2 Completed \n");
        printf ("****************************************\n");    
    
        /* CPINTC Testing has been completed. */
        printf ("**************************************************\n");
        printf ("************* CPINTC Testing Completed ***********\n");
        printf ("**************************************************\n");
        
        return;    
    }
    

    Regards

    Shankari G

  • Hello Shankari,

    It seems the complier does not compile the intvecs.asm. Benito had a similar issue in the ticket via the link below, but I have no idea he fixed it or not. 

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1004499/evmk2g-intcvectortable-undefined-symbol-in-ccs10-2/3712453?tisearch=e2e-sitesearch&keymatch=intvecs.asm#3712453

    I could understand the code you provided by using the CSL APIs, but I wanna know how to set ISTP into the address of the Interrupt Vector.

    Thanks.

  • Chunhua,

    I looked into the thread, you pointed.

    It seems, he had not continued using them; Instead he proceeded with CSL API, similar to the one, I pointed above.

    Regards

    Shankari G