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.

TMS320VC5416: How to write Interrupt Service routine

Other Parts Discussed in Thread: TMS320VC5416

Hi,

I am working with TMS320VC5416. I want to use external interrupt INT0, INT1, INT2.

I have check my code in simulator, when I set the IFR bit '0' (IFR = 0x0001), it does not jump to ISR. It jump to 0xFFC1 and INTM bit is also goes to 1.

Here is  my code.

/******************Code**********************/

volatile unsigned int *IMR = (volatile unsigned int *) 0x0000;
volatile unsigned int *IFR = (volatile unsigned int *) 0x0001;

void EXT_INT_ISR();


/****************Interrupt Handler**********************/
interrupt void EXT_INT_ISR()
{
         if( (*IFR & 0x01)==0x01)
         {
             
            *IFR &= 0xFE;
         }

         if( (*IFR & 0x02)==0x02 )
         {
        
               *IFR &= 0xFD;
         }

         if( (*IFR & 0x04)==0x04 )
         {
        
            *IFR &= 0xFB;  //
         }        
}

/***********************Main*******************/
void main(void)
{              
    
    unsigned short temp=0;
    unsigned char counter=0;

    *IMR= 0x07;
     asm(" RSBX  INTM ");
     asm(" nop");
     asm(" nop");
 

    while(1);
    
}

/**********************Linker Command File*******************************/

-c


-l C:\CCStudio_v3.3\C5400\cgtools\lib\rts_ext.lib

MEMORY {
   PAGE 0: /* program memory */

        PROG_RAM  : origin = 0x0080, length = 0x7F80

   
      /* boot interrupt vector table location */
        VECTORS : origin = 0xFF80, length = 0x80


   PAGE 1:

        DATA_RAM : origin = 0x8000, length = 0x8000
 



} /* MEMORY */


SECTIONS {
   .text    > PROG_RAM PAGE 0   
   .switch  > PROG_RAM PAGE 0       
   .cinit   > PROG_RAM PAGE 0
   .vectors > VECTORS  PAGE 0     
 
   .data    > DATA_RAM PAGE 1
   .bss     > DATA_RAM PAGE 1
   .const   > DATA_RAM PAGE 1
   .sysmem  > DATA_RAM PAGE 1
   .stack   > DATA_RAM PAGE 1
  
}

I think, I am missing some thing in the ISR.  Please Let me know if there is any issue in ISR.

void EXT_INT_ISR();


/****************Interrupt Handler**********************/
interrupt void EXT_INT_ISR()
{
         if( (*IFR & 0x01)==0x01)
         {
             
            *IFR &= 0xFE;
         }

         if( (*IFR & 0x02)==0x02 )
         {
        
               *IFR &= 0xFD;
         }

         if( (*IFR & 0x04)==0x04 )
         {
        
            *IFR &= 0xFB;  //
         }        
}

When I am running this code through XDS510 usb emulator.  When I give the interrupt on INT0 through Keypad, which is reflected by IFR = 0x0001. Now the cursor does not jump anywhere, it simply follow code.

Please let me know, if there is any issue in enabling interrupt or writing ISR.???????. Also describe how to write ISR for TMS320VC5416.

Thanks.

Regards

Rafaqat

  • Hi,

    You missed IRQ plugin. In other words, you need to write your isr function address to in your vector table. You said that it jumped to 0xFFC1. What is the value of 0xFFC1?

    If it is zero, you did not do IRQ plugin.The example can be found at CCSudio_v3.3\exmaples\dsk5416\csl\timer\timer1.

    Regards,

    Hyun

  • Hi,

    Hyun Kim said:

    Hi,

    You missed IRQ plugin. In other words, you need to write your isr function address to in your vector table. You said that it jumped to 0xFFC1. What is the value of 0xFFC1?

    If it is zero, you did not do IRQ plugin.The example can be found at CCSudio_v3.3\exmaples\dsk5416\csl\timer\timer1.

    Regards,

    Hyun

    You are right. I forget to place my isr  on interrupt vector table. Now my code work fine on simulator. On interrupt the cursor jumps to Interrupt Service routine and execute successfully (Setting the interrupt by writing 1 on specific bit of IFR from memory window). 

    When I switch to Emulator and trying to run same code. During loading I got error "Data Verification failed at 0xFF80 Please verify target memory map".

    My Interrupt vector table is mapped on default location 0xFF80.

    • main.c
    • vectors.asm
    • c5416.gel.
    • c5416.cmd

    Please let me know if I am missing any thing else.

    Waiting for your quick reply.

    6011.interrupt.rar

  • Hi Hyun,

    We move little bit forward. Now our code is loaded successfully. The problem was at reset vector the code does not jump to bootloader (0xF800). When you go through the vectors.asm.

    You will see at reset vector table.

    INT0: nop

              nop

              nop

              nop

    I replace this by

    INT0: BD 0F800H

              nop

              nop

    Now the code is loaded successfuly.

    When I am pressing keypad button which will reflect at IFR bits (INT0, INT,1NT2)  but the cursor does not jump to ISR.

    Here is modified vectors.asm

    /////////////////////////////////////////////////////////////////////////////////////////////////////

               
                .sect ".vectors"
                .global _int0_handled,_int1_handled,_int2_handled
                .ref _ex_int00,_ex_int01,_ex_int02
                ;for reset & interrupt vectors

    INT0:        BD 0F800h
        
                nop;nop
                nop;nop

    INT1:        nop ;branch to interrupt vector 2
                nop
                nop;nop
                nop;nop
    INT2:         nop
                nop
                nop
                nop
    INT3:         nop
                nop
                nop
                nop
    INT4:         nop
                nop
                nop
                nop
    INT5:         nop
                nop
                nop
                nop
    INT6:         nop
                nop
                nop
                nop
    INT7:         nop
                nop
                nop
                nop
    INT8:         nop
                nop
                nop
                nop
    INT9:         nop
                nop
                nop
                nop
    INT10:         nop
                nop
                nop
                nop
    INT11:         nop
                nop
                nop
                nop
    INT12:         nop
                nop
                nop
                nop
    INT13:         nop
                nop
                nop
                nop
    INT14:         nop
                nop
                nop
                nop
    INT15:         nop
                nop
                nop
                nop
    INT16:         b _ex_int00 ;branch to interrupt handler
    _int0_handled: ret
                nop
                
    INT17:         b _ex_int01 ;branch to interrupt handler
    _int1_handled: ret
                nop
                
    INT18:         b _ex_int02 ;branch to interrupt handler
    _int2_handled: ret
                nop
                nop
                nop
    ///////////////////////////////////////////////////////////////////////////////////////////

    Waiting for your response.

    Regards,