需要重定位中断向量的时候,需要使用汇编语言(以外部中断的使用为例):
中断配置,先配置一个空的中断向量表,再程序中利用csl的API函数来关联相应的中断函数到相应的中断向量上:
[html] view plain copy
print?
- *
- * Copyright (C) 2003 Texas Instruments Incorporated
- * All Rights Reserved
- *
- *
- *---------vectors_dma2.s55---------
- *
- * Assembly file to set up interrupt vector table
- *
- .sect ".vectors"
-
- *------------------------------------------------------------------------------
- * Global symbols defined here and exported out of this file
- *------------------------------------------------------------------------------
- .global _VECSTART
- *------------------------------------------------------------------------------
- * Global symbols referenced in this file but defined somewhere else.
- * Remember that your interrupt service routines need to be referenced here.
- *------------------------------------------------------------------------------
- .ref _c_int00
-
- .def nmi, int0, int1, int2, int3, int4, int5, int6
- .def int7, int8, int9, int10, int11, int12, int13
- .def int14, int15, int16, int17, int18, int19, int20
- .def int21, int22, int23, int24, int25, int26, int27
- .def int28, int29
-
- _VECSTART:
- .ivec _c_int00,c54x_stk
- nmi .ivec no_isr
- nop_16
- int0 .ivec no_isr
- nop_16
- int1 .ivec no_isr
- nop_16
- int2 .ivec no_isr
- nop_16
- int3 .ivec no_isr
- nop_16
- int4 .ivec no_isr
- nop_16
- int5 .ivec no_isr
- nop_16
- int6 .ivec no_isr
- nop_16
- int7 .ivec no_isr
- nop_16
- int8 .ivec no_isr
- nop_16
- int9 .ivec no_isr
- nop_16
- int10 .ivec no_isr
- nop_16
- int11 .ivec no_isr
- nop_16
- int12 .ivec no_isr
- nop_16
- int13 .ivec no_isr
- nop_16
- int14 .ivec no_isr
- nop_16
- int15 .ivec no_isr
- nop_16
- int16 .ivec no_isr
- nop_16
- int17 .ivec no_isr
- nop_16
- int18 .ivec no_isr
- nop_16
- int19 .ivec no_isr
- nop_16
- int20 .ivec no_isr
- nop_16
- int21 .ivec no_isr
- nop_16
- int22 .ivec no_isr
- nop_16
- int23 .ivec no_isr
- nop_16
- int24 .ivec no_isr
- nop_16
- int25 .ivec no_isr
- nop_16
- int26 .ivec no_isr
- nop_16
- int27 .ivec no_isr
- nop_16
- int28 .ivec no_isr
- nop_16
- int29 .ivec no_isr
- nop_16
-
- *------------------------------------------------------------------------------
- * This is a dummy interrupt service routine used to initialize the IST.
- *------------------------------------------------------------------------------
- .text
- .def no_isr
- no_isr:
- b #no_isr
- *------------------------------------------------------------------------------ [url=][/url]
** Copyright (C) 2003 Texas Instruments Incorporated* All Rights Reserved***---------vectors_dma2.s55---------** Assembly file to set up interrupt vector table* .sect ".vectors"*------------------------------------------------------------------------------* Global symbols defined here and exported out of this file*------------------------------------------------------------------------------ .global _VECSTART*------------------------------------------------------------------------------* Global symbols referenced in this file but defined somewhere else. * Remember that your interrupt service routines need to be referenced here.*------------------------------------------------------------------------------ .ref _c_int00 .def nmi, int0, int1, int2, int3, int4, int5, int6 .def int7, int8, int9, int10, int11, int12, int13 .def int14, int15, int16, int17, int18, int19, int20 .def int21, int22, int23, int24, int25, int26, int27 .def int28, int29_VECSTART: .ivec _c_int00,c54x_stknmi .ivec no_isr nop_16int0 .ivec no_isr nop_16int1 .ivec no_isr nop_16int2 .ivec no_isr nop_16int3 .ivec no_isr nop_16int4 .ivec no_isr nop_16int5 .ivec no_isr nop_16int6 .ivec no_isr nop_16int7 .ivec no_isr nop_16int8 .ivec no_isr nop_16int9 .ivec no_isr nop_16int10 .ivec no_isr nop_16int11 .ivec no_isr nop_16int12 .ivec no_isr nop_16int13 .ivec no_isr nop_16int14 .ivec no_isr nop_16int15 .ivec no_isr nop_16int16 .ivec no_isr nop_16int17 .ivec no_isr nop_16int18 .ivec no_isr nop_16int19 .ivec no_isr nop_16int20 .ivec no_isr nop_16int21 .ivec no_isr nop_16int22 .ivec no_isr nop_16int23 .ivec no_isr nop_16int24 .ivec no_isr nop_16int25 .ivec no_isr nop_16int26 .ivec no_isr nop_16int27 .ivec no_isr nop_16int28 .ivec no_isr nop_16int29 .ivec no_isr nop_16*------------------------------------------------------------------------------* This is a dummy interrupt service routine used to initialize the IST.*------------------------------------------------------------------------------ .text .def no_isrno_isr: b #no_isr*------------------------------------------------------------------------------[html] view plain copy
print?
- void INTconfig()
- {
- /* Temporarily disable all maskable interrupts */
-
- IRQ_setVecs((Uint32)(&VECSTART));
-
- /* Temporarily disable all maskable interrupts */
-
- old_intm = IRQ_globalDisable();
-
- /* Get Event Id associated with External INT1(8019), for use with */
-
- eventId0 = IRQ_EVT_INT0;
-
- /* Clear any pending INT1 interrupts */
-
- IRQ_clear(eventId0);
-
- /* Place interrupt service routine address at */
-
- /* associated vector location */
-
- IRQ_plug(eventId0,&int1);
-
- /* Enable INT1(8019) interrupt */
-
- IRQ_enable(eventId0);
-
- /* Enable all maskable interrupts */
-
- IRQ_globalEnable();
- }
[url=][/url]
void INTconfig(){ /* Temporarily disable all maskable interrupts */ IRQ_setVecs((Uint32)(&VECSTART)); /* Temporarily disable all maskable interrupts */ old_intm = IRQ_globalDisable(); /* Get Event Id associated with External INT1(8019), for use with */ eventId0 = IRQ_EVT_INT0; /* Clear any pending INT1 interrupts */ IRQ_clear(eventId0); /* Place interrupt service routine address at */ /* associated vector location */ IRQ_plug(eventId0,&int1); /* Enable INT1(8019) interrupt */ IRQ_enable(eventId0); /* Enable all maskable interrupts */ IRQ_globalEnable(); }
程序:
[html] view plain copy
print?
- main()
- {
- /*初始化CSL库*/
- CSL_init();
- /*EMIF为全EMIF接口*/
- CHIP_RSET(XBSR,0x0a01);
- /*设置系统的运行速度为144MHz*/
- PLL_config(&myConfig);
- //设置并使能5509A芯片的INT0中断(EXINT中断)
- INTconfig();
- while(1);
- }
[url=] [/url]
main(){ /*初始化CSL库*/ CSL_init(); /*EMIF为全EMIF接口*/ CHIP_RSET(XBSR,0x0a01); /*设置系统的运行速度为144MHz*/ PLL_config(&myConfig); //设置并使能5509A芯片的INT0中断(EXINT中断) INTconfig(); while(1);}
[html] view plain copy
print?
- //External INT0(EXINT)中断处理函数
- interrupt void int1()
- {
- printf("EXINT ouccers\n");
- }
[url=] [/url]
//External INT0(EXINT)中断处理函数interrupt void int1(){ printf("EXINT ouccers\n");}
设置好IVPD(IVPH)后,还需要在cmd文件里重新指明中断向量表存放在相应的位置。
参考http://www.eptw.com/bbs/viewthread.php?tid=2619
IVPD和IVPH的赋值和.CMD文件中的存储器定位有关,BOOT origin=8000h,length=00100h vectors:>BOOT,如上面定位是80H,则初始化IVPD和IVPH的值时就是MOV #0x80,mmap(IVPD)。
三、TMS320VC5509A的时钟(PLL)
1. 时钟电路
TMS320VC5509A的内部振荡器复位时为有效。内部振荡器需要外部晶体支持,连接到X1和X2/CLKIN引脚。如果不用内部振荡器,外部时钟连接到X2/CLKIN引脚,X1引脚悬空。当内部振荡器作为时钟源输入到PLLs时,振荡器时钟可以倍频或分频成为CPU时钟、USB时钟等。
电路连接图如下图所示:
1) Clock Generation in Bypass Mode (DPLL Disabled)
通过时钟模式设置寄存器的BYPASS_DIV位可以设置DPLL失效。
2) Clock Generation in Lock Mode (DPLL Synthesis Enabled)
The frequency of the reference clock provided at the X2/CLKIN pin can be multiplied by a synthesis factor of N to generate the internal CPU clock cycle. The synthesis factor is determined by:
where: M = the multiply factor set in the PLL_MULT field of the clock mode register
D = the divide factor set in the PLL_DIV field of the clock mode register
Valid values for M are (multiply by) 2 to 31. Valid values for DL are (divide by) 1, 2, 3, and 4.
|