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.

C6747 timer1 interrupt

i am starting on C6747 interrupt handling and i created a simple project, in witch i want a interrupt to be generated once the timer1 finishes a circle.

but it seems the interrupt is generated (from the value of INTCTLSTAT1 that i observed) ,while my interrupt function "xint0_isr" is never executed....can some one help me ..

bty, followed are my main.c , my interrupt vector table and my link file

//---------------main.c--------------//

extern cregister volatile unsigned int AMR;     /* Address Mode Register      */
extern cregister volatile unsigned int CSR;     /* Control Status Register    */
extern cregister volatile unsigned int IFR;     /* Interrupt Flag Register    */
extern cregister volatile unsigned int ISR;     /* Interrupt Set Register     */
extern cregister volatile unsigned int ICR;     /* Interrupt Clear Register   */
extern cregister volatile unsigned int IER;     /* Interrupt Enable Register  */
extern cregister volatile unsigned int ISTP;    /* Interrupt Service Tbl Ptr  */
extern cregister volatile unsigned int IRP;     /* Interrupt Return Pointer   */
extern cregister volatile unsigned int NRP;     /* Non-maskable Int Return Ptr*/
extern cregister volatile unsigned int IN;      /* General Purpose Input Reg  */
extern cregister volatile unsigned int OUT;     /* General Purpose Output Reg */

#define INTMUX1      *( volatile Uint32* )(0x01800104)
#define INTCTLSTAT1  *( volatile Uint32* )(0x01C21044)
 

#include <C6747.h>
#include<stdio.h>
void Timer1_Init(void)
{
    TIMER1_TRC   = 0x00000080; //timer1 control register
    TIMER1_PRD12 = 0x00000030;
    TIMER1_TIM12 = 0;
    INTCTLSTAT1 &= ~0xFF;
    INTCTLSTAT1 |= 0x00010001;   // enable timer1 interrupt
    TIMER1_TGCR  = 0x05;         // let timer1 works in dual 32bit unchained mode and enable time1
}
Uint8 cnt = 0;
void main(void)
{  
    C6747_init( );
    ISTP = 0xFFF00000;  //start of the c_int0
    INTMUX1 &= ~0xFF;   // clear out INTSEL4 field
    INTMUX1 |= 40;      // INTSEL4=40
 IER |= 0x00000013;   // IE4=1
 CSR |= 0x00000001;   // intrrupt gloabe enabel
 Timer1_Init();

 while(1);

}

interrupt void xint0_isr(void)
{
printf("interrupt occured\n");
cnt++;
}

//----------------vector.asm-----------//

; Global symbols defined here and exported out of this file
   .global _intcVectorTable
   .global _c_int00
   .global _xint0_isr
   .global _vector3
   .global _vector4
   .global _vector5
   .global _vector6
   .global _vector7
   .global _vector8
   .global _vector9
   .global _vector10
   .global _vector11
   .global _vector12
   .global _vector13
   .global _vector14
   .global _vector15

 

; This is a macro that instantiates one entry in the interrupt service table.

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

 

; This is a dummy interrupt service routine used to initialize the IST.
_vec_dummy:
  B    B3
  NOP  5

 

; This is the actual interrupt service table (IST).
 .sect  ".vectors"
 .align 1024

_intcVectorTable:
_vector0:   VEC_ENTRY _c_int00      ;RESET
_vector1:   VEC_ENTRY _vec_dummy    ;NMI
_vector2:   VEC_ENTRY _vec_dummy    ;RSVD
_vector3:   VEC_ENTRY _vec_dummy    ;RSVD
_vector4:   VEC_ENTRY _xint0_isr  ;isr0
_vector5:   VEC_ENTRY _vec_dummy  ;isr1
_vector6:   VEC_ENTRY _vec_dummy  ;isr2
_vector7:   VEC_ENTRY _vec_dummy  ;isr3
_vector8:   VEC_ENTRY _vec_dummy
_vector9:   VEC_ENTRY _vec_dummy
_vector10:  VEC_ENTRY _vec_dummy
_vector11:  VEC_ENTRY _vec_dummy
_vector12:  VEC_ENTRY _vec_dummy
_vector13:  VEC_ENTRY _vec_dummy
_vector14:  VEC_ENTRY _vec_dummy
_vector15:  VEC_ENTRY _vec_dummy

//---------------link.cmd-----------------//

-l rts64plus.lib
-l ..\..\..\C6747_common\lib\C6747bsl.lib
-stack 0x1000
-heap 0x1000

MEMORY
{
    VECS:        o = 0xFFF00000  l = 0x00080000
    ARMRAM:      o = 0xFFFF0080  l = 0x00001f80
    DSPRAM:      o = 0x11800000  l = 0x00040000
    SHAREDRAM:   o = 0x80000000  l = 0x00020000
    SDRAM:       o = 0xC0000000  l = 0x20000000
}

SECTIONS
{
    .bss        >   SHAREDRAM
    .cinit      >   SHAREDRAM
    .cio        >   SHAREDRAM
    .const      >   SHAREDRAM
    .stack      >   SHAREDRAM
    .sysmem     >   SHAREDRAM
    .text       >   SHAREDRAM
    .switch     >   SHAREDRAM
    .far        >   SHAREDRAM
    .vectors    >   SHAREDRAM
}

  • Feng Sun,

    A good example for you to look at is located in the PSP package.

    If you do not already have the BIOSPSP package, you can find here:
    http://software-dl.ti.com/dsps/dsps_registered_sw/sdo_sb/targetcontent/psp/bios_psp/1.30.xx/1.30.00.05/BIOSPSP_01_30_00_05_Setup.exe

    The example will be located following this directory structure:
    \packages\ti\pspiom\cslr\evm6747\examples\timer\

    Hope this helps.

    -Kevin

  • Feng Sun,

    As a side note, it appears that updating the linker command file may fix the issue.

    In the main() function, ISTP is assigned to 0xFFF00000. (This corresponds to VECS in the linker command file.)

    However, the section .vectors (which corresponds to _intcVectorTable in vector.asm) is assigned to SHAREDRAM and not VECS.

    I would suggest modifying ".vectors > SHAREDRAM" to ".vectors > VECS" as a starting point to debug.

    -Kevin

  • sorry for the mistake...actually .vectors was mapped into VECS before i came for help, i just type the wrong version of my link file..sorry again

    but i think i have ...kind of  fixed the problem, although i don't know why it works like this .  what i have done were:

    1.build the project again

    2. reload

    3. i found that  _c_int0 was in address 0x80003800, so i juest change my ISTP into that and rebult and reloaded, ....and it worked 

     

    so here is some other questions come up:

    1. how to set ISTP correctly, i mean not like the kind of the way i just used.

    2. there are four INT pins(INT0-INT3) on C6747, how to use them as a interrupt generater?  right now i can just use them as a common GPIO pin

  • byt, it is such a big surprise to see u reply to my post so quick...thanks a lot for what u have said and the time u have spent

  • Feng Sun,

    Just as a sanity check, you may check that the new linker command file is called on a rebuild. I ask this because _c_int00 should be located in the section .vectors, which if assigned to VECS would be located somewhere in the range of 0xFFF00000 to 0xFFF8000. Regardless, you should be able to assign VECS to SHAREDRAM without any trouble. To answer your questions:

    so here is some other questions come up:

    1. how to set ISTP correctly, i mean not like the kind of the way i just used.
    One solution is to assign ISTP to intcVectorTable (located in vector.asm), which is essentially the address of the starting point of the interrupt vector table. This can be done by adding the following lines of code to main.c file.

    extern
    void intcVectorTable (void);            // Add this to top of file
    ISTP = (unsigned int)intcVectorTable;

    2. there are four INT pins(INT0-INT3) on C6747, how to use them as a interrupt generater?  right now i can just use them as a common GPIO pin
    I am not entirely sure which pins you are referring to. Do you mind elaborating a bit here? Thanks!

    Out of curiosity, which version of CCS are you using?

    -Kevin

  • THANKS a lot!

    i am now using CCS Ver.3.3. 

    about the INT pins, maybe i was a little bit confused because the development kit we bought (DEC6747 by SEED) use four of GPIO pins as INT0-INT4.

  • Feng Sun,

    Glad to see everything is working now!

    If you don't mind, please mark the post which was the most beneficial as "Verified Answer" to notify others that this forum thread contains a solution.

    about the INT pins, maybe i was a little bit confused because the development kit we bought (DEC6747 by SEED) use four of GPIO pins as INT0-INT4.
    If there is still confusion, let me know and I will see if I can better understand the problem. The context (source code) may be beneficial.

    Thanks,
    Kevin

  • Thanks i tried that and it worked.

    Now i am moving on to let the C6747 to read frames of data from an outside FIFO built in a FPGA or sth.

    The data is read from EMIFA using EDMA, every reading process is triggered by a rising edge of GPIO2[4]

    The problem here is that when a rising edge is provided on the GPIO2[4] pin, the GPIO interrupt is triggered and corresponding function is executed, but the EDMA refuses to work. 

    Then i tried to run in CCS step by step, and i found that when

    void set_EMIFA(){
    ......

        AEMIF_A4CR |= 0 << 31 |                  //set Asyncronise clocks  in CE4CEG
                      1 << 30 |
                      (1 & 0xFF) << 13 |
                      (3 & 0x0F) <<  7 |
                      (2 & 0x0F) <<  4 |
                      (0 & 0x0F) <<  0;

    ......
    }

    is executed, nothing happened on the register CE4CFG, and it remained 0.

     

     

    followed is my main.c

    #define FIFO_ADDR      0x67000000
    #define BUFF_ADDR    0x80000000
    #define INTMUX1            *( volatile Uint32* )(0x01800104)
    #define FIFO_DEPTH    256
    #define NUM_FRAMES 8

    #include<C6747.h>
    #include<c6x.h>
    #include<stdio.h>
     
    int num_frames = NUM_FRAMES;
    int done = 0;

    void set_EDMA();
    void set_intr();
    void set_EMIFA();
    void set_GPIO();
    interrupt void c_int04();
    interrupt void c_int05();


    void main(){ 
        ISTP = (unsigned int)vectors;
        C6747_init();
        CSR &= ~0x01;   // intrrupt gloabe disabel
        set_GPIO();
        set_EMIFA();
        set_EDMA();
        set_intr();
        while (!done);
        printf("DONE \n\n");
        EDMA_ICR |= 0x01;
    }
    void set_GPIO(){                                             // Set GPIO2[4] to be HF in pin
         GPIO_DIR23 |= 0x1<<4;                          // direct: input
         GPIO_BINTEN &= ~0xFF;          
         GPIO_BINTEN |= 0x1<<2;                       // enable GPIO band2 interrupt
         GPIO_SET_RIS_TRIG23 |= 0x1<<4;    // enable rising edge interrupt
         GPIO_CLR_FAL_TRIG23 |= 0x1<<4;   // disable falling eged interrpt
    }
    void set_EDMA(){
               /*EDMA initialization */
                  SAOPT0 = 0x00100071;                   // lowest priority
                  QWMTHRA =(16<<8u)|(16 & 0xFF);
                  EMCR =  0xFFFFFFFF;                     // clear previous missed events
                  CCERRCLR = 0xFFFFFFFF;           // Clear previous errs
      
             /* Programming DMA Channel (and Param set) */
                 DMAQNUM0=0x0;                              // Event is queued in queue 0
                 CH0_OPT = 0x00100000;             

                 CH0_SRC = FIFO_ADDR;
                 CH0_A_B_CNT = ((1 << 16u) | ((FIFO_DEPTH / 2) & 0xFFFFu));    /* ACNT = 128, BCNT = 1 */
                 CH0_DST = BUFF_ADDR;
                 CH0_SRC_DST_BIDX = (0 << 16u) | ((FIFO_DEPTH / 2) & 0xFFFFu);    /* SRC_BIDX = 0, DST_BIDX = 128 */
                 CH0_LINK_BCNTRLD = (1 << 16u) | 0xFFFFu;    /* LINK = 0xFFFF, BCNTRLD = 1 */
                 CH0_SRC_DST_CIDX = 0;
                 CH0_CCNT = 1;
                 EDMA_ISER |= 0x01; //enable channel0 complete interrupt
    }
    void set_EMIFA(){
           KICK0R = 0x83e70b13;
           KICK1R = 0x95A4F1E0;    
           PINMUX18 = 0x11100012;  // EMA_WE_DQM[1-0],EMA_WE,EMA_OE,EMA_CS[5]
           KICK0R = 0;                // Kick0 register + data (unlock)
           KICK1R = 0;                // Kick1 register + data (unlock)
           AEMIF_A4CR = 0;
           AEMIF_A4CR |=  0 << 31 |                  //set Asyncronise clocks
                                          1 << 30 |
                         (1 & 0xFF) << 13 |
                          (3 & 0x0F) <<  7 |
                          (2 & 0x0F) <<  4 |
                           (0 & 0x0F) <<  0;
    }

    void set_intr(){
                      INTMUX1 &= ~0xFFFF;                   // clear out INTSEL4 INTSEL5 field
                      INTMUX1 |= 49 |(50<<8);                // INTSEL4=49(GPIO BANDK2), INTSEL5=50(EDMACC0)
                      IER |= 0x00000033;                          // IE4=1, IE5=1
                      CSR |= 0x00000001;                       // intrrupt gloabe enabel
    }

    interrupt void c_int05(){  /* DMA complete Interrupt */
                  num_frames--;/* Decrement frame counter */
                  printf(" one frame has been transmitted\n");
                  EDMA_ICR |= 0x01;
                  if (num_frames > 0)
                          IER |= 0x01<<4;    /* enable GPIO bank2 interrupt, to detect the next rising edge of HF */
                  else
                         done = 1;
    }

    interrupt void c_int04() {
                     IER &= ~(0x01<<4);  //disable GPIO bank2 interrupt
                                                                /* so that any toggling of the HF flag is disregarded until the DMA*/
                                                                /* transfer is complete.         */
                     if (num_frames > 0)
                          EDMA_ESR |= 0x1;    /* Starts the DMA transfer, if haven’t transferred the desired number of frames.  */
                     printf("a new frame is started\n");
    }