TI C64X DSP interrupt vector table configuration (hardware interrupt)
[Copy link]
1. Write an interrupt service routine
Write an ISR function c_intXX in the .c source file for interrupt processing, such as:
interrupt void c_intXX (void)
{
…;
}
Note: For hardware interrupts, XX = 00~15.
2. Initialize the interrupt vector table and configure the corresponding interrupt vector in the interrupt vector table in the memory segment
The first step is to locate the interrupt vector table in a certain memory segment. We can configure the memory mapping of the interrupt vector table in the cmd file, such as:
MEMORY
{
VECTORS: org = 00000000h, len = 00000400h
L2SRAM: org = 00000400h, len = 00100000h
SDRAM: org = 80000000h, len = 10000000h
}
SECTIONS
{
.vecs :> VECTORS
.data :> L2SRAM
.text :> L2SRAM
.switch :> L2SRAM
.stack :> L2SRAM
.bss :> L2SRAM
.cinit :> L2SRAM
.far :> L2SRAM
.cio :> L2SRAM
.const :> L2SRAM
.sysmem :> SDRAM
.tables :> L2SRAM
}
Then create an .asm file to configure the interrupt vector in the interrupt vector table. We need to declare some global variables so that other source files can reference these variables or reference variables of other source files, such as:
.global _vectors
.global _c_int00
.global _vector1
.global _vector2
.global _vector3
.global _vector4
.global _vector5
.global _vector6
.global _vector7
.global _c_int08 ; c_int08 interrupt service routine corresponding to the main() function (assuming that the EDMA interrupt is processed)
.global _vector9
.global _vector10
.global _vector11
.global _vector12
.global _vector13
.global _vector14
.global _vector15
Because the _c_int00 interrupt of rts, that is, the RESET interrupt, is referenced, this symbol needs to be introduced:
.ref _c_int00
In order to insert the address of the interrupt service routine, that is, the interrupt vector, into the interrupt vector table, a macro can be defined:
VEC_ENTRY .macro addr
STW B0,*--B15
MVKL addr,B0
MVKH addr,B0
B B0
LDW *B15++,B0
NOP 2
NOP
NOP
.endm
In order to initialize the interrupt vector in the interrupt vector table, a virtual interrupt vector can be defined:
_vec_dummy:
B B3
NOP 5
Next, you can configure the interrupt vector table:
.sect ".vecs"
.align 1024
_vectors:
_vector0: VEC_ENTRY _c_int00 ;RESET interrupt
_vector1: VEC_ENTRY _vec_dummy ;NMI non-maskable interrupt
_vector2: VEC_ENTRY _vec_dummy ; Reserve interrupt 1
_vector3: VEC_ENTRY _vec_dummy ; Reserve interrupt 2
_vector4: VEC_ENTRY _vec_dummy ; External interrupt INT4
_vector5: VEC_ENTRY _vec_dummy ; External interrupt INT5
_vector6: VEC_ENTRY _vec_dummy ; External interrupt INT6
_vector7: VEC_ENTRY _vec_dummy ; External interrupt INT7
_vector8: VEC_ENTRY _c_int08 ; EDMA controller interrupt EDMAINT, corresponding to c_int08 ISR
_vector9: VEC_ENTRY _vec_dummy; JTAGRTDX interrupt
_vector10: VEC_ENTRY _vec_dummy; EMIF_SDRAM_Timer interrupt
_vector11: VEC_ENTRY _vec_dummy; McBSP_0_Receive interrupt
_vector12: VEC_ENTRY _vec_dummy; McBSP_1_Transmit interrupt
_vector13: VEC_ENTRY _vec_dummy; Host_Port_Host_to_DSP interrupt
_vector14: VEC_ENTRY _vec_dummy; Timer0 interrupt
_vector15: VEC_ENTRY _vec_dummy; Timer1 interrupt
3. Specify the defined interrupt vector table in the C program and enable the CPU interrupt function
In the C program, it is more convenient to use the IRQ module of CSL to set the interrupt. Before setting, you need to externally link the interrupt vector table symbol of the above asm program:
extern far void vectors(); //The reason why it is called vectors is that the C compiler automatically renames it to _vectors after compiling
After referencing the interrupt vector table, you can set the interrupt:
IRQ_setVecs(vectors); //Point to the interrupt vector table defined in asm
IRQ_nmiEnable();
IRQ_globalEnable();
IRQ_map(IRQ_EVT_EDMAINT, 8); //Map events to the specified physical interrupt number
IRQ_reset(IRQ_EVT_EDMAINT);
4. Start the interrupt source, such as the EDMA controller interrupt
At this point, the interrupt service routine c_int8 can serve the EDMAINT interrupt, and the configuration of other hardware interrupt vectors is similar.
|