DSP

DM6437下无DSP/BIOS中断

2019-07-13 17:20发布

之前一直在调试DM6437的中断,因为时间的问题以及用到的资源不多,所以没有使用DSP/BIOS,由于网上资源比较少,因此将这方面对资料与大家分享下。我的例子中使用的是定时器产生中断,该中断映射到中断14。 6437有优先级从高到低三种类型的中断:RESET NMI 可屏蔽中断(INT4-INT15) 对于我们一般使用INT4-15比较多,实现的步骤:

1 首先是把中断向量表定位到某一内存段中,我们可以在cmd文件中配置中断向量表的内存映射

/* * Copyright 2006 by Spectrum Digital Incorporated. * All rights reserved. Property of Spectrum Digital Incorporated. */ /* * Linker command file * */ -l rts64plus.lib //-l ....libevmdm6437bsl.lib -l E:CCS_WorkSpaceevmdm6437_v2libevmdm6437bsl.lib -l C:c64plus-imglib_2_02_00_00lib argetimglib2.l64P -l C:c64plus-imglib_2_02_00_00lib argetimglib2_cn.l64P -stack 0x00001000 /* Stack Size */ -heap 0x00001000 /* Heap Size */ MEMORY { L2RAM: o = 0x10800800 l = 0x00020000 DDR2: o = 0x80000000 l = 0x10000000 INT: o = 0x10800400 l = 0x00000400 } SECTIONS { .bss > L2RAM .cinit > DDR2 .cio > L2RAM .const > L2RAM .data > L2RAM .far > DDR2 .stack > L2RAM .switch > L2RAM .sysmem > DDR2 .text > L2RAM .ddr2 > DDR2 .vectors > INT }

2.设置中断向量表,注意cmd文件中的“.vectors"要与中断向量表中的.sect ".vectors"相同。

; Global symbols defined here and exported out of this file .global _vectors .global _c_int00 .global _vector1 .global _vector2 .global _vector3 .global _vector4 .global _vector5 .global _vector6 .global _vector7 .global _vector8 .global _vector9 .global _vector10 .global _vector11 .global _vector12 .global _vector13 .global _time0_isr .global _vector15 ;Global symbols referenced in this file but defined somewhere else ;Remember that your interrupt service routines need to be referenced here .ref _c_int00 .ref _time0_isr ; 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 _vectors: _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 _vec_dummy ;isr0 _vector5: VEC_ENTRY _vec_dummy ;isr1 _vector6: VEC_ENTRY _vec_dummy ;isr2 _vector7: VEC_ENTRY _vec_dummy ;isr3 _vector8: VEC_ENTRY _vec_dummy ;isr4 _vector9: VEC_ENTRY _vec_dummy ;isr5 _vector10: VEC_ENTRY _vec_dummy ;isr6 _vector11: VEC_ENTRY _vec_dummy ;isr7 _vector12: VEC_ENTRY _vec_dummy ;isr8 _vector13: VEC_ENTRY _vec_dummy ;isr9 _vector14: VEC_ENTRY _time0_isr ; hookup the c_int14 ISR in main() _vector15: VEC_ENTRY _vec_dummy ;

3.中断初始化

void int_init() { CSR = 0x100; //disable all interrupts IER = 1; //disable all interrupts except NMI ICR = 0xffff; //clear all pending interrupts ISTP = 0x10800400; //set the ISTP equals the INT address in the .cmd INTC_EVTCLR0 = 0xFFFFFFFF; INTC_EVTCLR1 = 0xFFFFFFFF; INTC_EVTCLR2 = 0xFFFFFFFF; INTC_EVTCLR3 = 0xFFFFFFFF; INTC_EVTMASK0 = 0xFFFFFFEF; //Timer0-TINT12 is combined INTC_EVTMASK1 = 0xFFFFFFFF; INTC_EVTMASK2 = 0xFFFFFFFF; INTC_EVTMASK3 = 0xFFFFFFFF;  INTC_INTMUX3 = 0x00040000; //map Timer0-TINT12 to INT14}其中IER,CSR,ICR,ISTP在SPRU732可以查到。Timer0-TINT12的事件号为4,可以在tms320dm6437.pdf的200页查找到。为了不屏蔽Timer0-TINT12,因此设置INTC_EVTMASK0 = 0xFFFFFFEF; //Timer0-TINT12 is combined 还需要将事件映射到中断上,方法为将事件号写入中断对应的寄存器位,本例子中映射为14号中断:   INTC_INTMUX3 = 0x00040000; //map Timer0-TINT12 to INT14EVTMASKn和INTMUXn在spru871k.pdf查找。 

4 中断处理函数

 interrupt void time0_isr() { printf("%d ", i); i++; } 其中关键字interrupt是必须,注意中断处理函数的名字与中断向量表中的名字_time0_isr对应。  可惜无法传文件。