DSP

DSP—2812、28335用C语言来实现中断的完整说明

2019-07-13 10:01发布

关于F2812中用C语言来实现中断的说明
1.首先在.cmd中定位系统中断表:
MEMORY
{
PAGE 0 : 
......................................
PAGE 1 : 
......................................
PIE_VECT : origin = 0x000D00, length = 0x000100
...................................... 
}
SECTIONS
{
................................... 
PieVectTable : > PIE_VECT, PAGE = 1
.....................................
}
2.在C中制定该中断的结构体:
#pragma DATA_SECTION(PieVectTable,"PieVectTable");
struct PIE_VECT_TABLE PieVectTable;(在DSP28_GlobalVariableDefs.C中初始化)
3.用一组常数(按照中断向量的顺序)初始化该名字为PIE_VECT_TABLE的表:
typedef interrupt void(*PINT)(void);这里有些一问,一下应该为函数名??

// Define Vector Table:
struct PIE_VECT_TABLE {

// Reset is never fetched from this table. 
// It will always be fetched from 0x3FFFC0 in either
// boot ROM or XINTF Zone 7 depending on the state of
// the XMP/MC input signal. On the F2810 it is always
// fetched from boot ROM. 

PINT PIE1_RESERVED; 
PINT PIE2_RESERVED;
PINT PIE3_RESERVED;
PINT PIE4_RESERVED;
PINT PIE5_RESERVED;
PINT PIE6_RESERVED;
PINT PIE7_RESERVED;
PINT PIE8_RESERVED;
PINT PIE9_RESERVED;
PINT PIE10_RESERVED;
PINT PIE11_RESERVED;
PINT PIE12_RESERVED;
PINT PIE13_RESERVED;

// Non-Peripheral Interrupts:
PINT XINT13; // XINT13
PINT TINT2; // CPU-Timer2
PINT DATALOG; // Datalogging interrupt
PINT RTOSINT; // RTOS interrupt
PINT EMUINT; // Emulation interrupt
PINT XNMI; // Non-maskable interrupt
PINT ILLEGAL; // Illegal operation TRAP
PINT USER0; // User Defined trap 0
PINT USER1; // User Defined trap 1
PINT USER2; // User Defined trap 2
PINT USER3; // User Defined trap 3
PINT USER4; // User Defined trap 4
PINT USER5; // User Defined trap 5
PINT USER6; // User Defined trap 6
PINT USER7; // User Defined trap 7
PINT USER8; // User Defined trap 8
PINT USER9; // User Defined trap 9
PINT USER10; // User Defined trap 10
PINT USER11; // User Defined trap 11

// Group 1 PIE Peripheral Vectors:
PINT PDPINTA; // EV-A
PINT PDPINTB; // EV-B
PINT rsvd1_3;
PINT XINT1; 
PINT XINT2;
PINT ADCINT; // ADC
PINT TINT0; // Timer 0
PINT WAKEINT; // WD

.............
.............
// Group 12 PIE Peripheral Vectors:
PINT rsvd12_1;
PINT rsvd12_2;
PINT rsvd12_3;
PINT rsvd12_4;
PINT rsvd12_5;
PINT rsvd12_6;
PINT rsvd12_7;
PINT rsvd12_8;
};
然后在使我们在.cmd文件中定义的表有以上属性:
extern struct PIE_VECT_TABLE PieVectTable;(在.h文件中)
4.初始化该表(在.c文件中)使之能够为主程序所使用:
const struct PIE_VECT_TABLE PieVectTableInit = {

PIE_RESERVED, // Reserved space
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 
PIE_RESERVED, 


// Non-Peripheral Interrupts
INT13_ISR, // XINT13 or CPU-Timer 1
INT14_ISR, // CPU-Timer2
DATALOG_ISR, // Datalogging interrupt
RTOSINT_ISR, // RTOS interrupt
EMUINT_ISR, // Emulation interrupt
NMI_ISR, // Non-maskable interrupt
ILLEGAL_ISR, // Illegal operation TRAP
USER0_ISR, // User Defined trap 0
USER1_ISR, // User Defined trap 1
USER2_ISR, // User Defined trap 2
USER3_ISR, // User Defined trap 3
USER4_ISR, // User Defined trap 4
USER5_ISR, // User Defined trap 5
USER6_ISR, // User Defined trap 6
USER7_ISR, // User Defined trap 7
USER8_ISR, // User Defined trap 8
USER9_ISR, // User Defined trap 9
USER10_ISR, // User Defined trap 10
USER11_ISR, // User Defined trap 11

// Group 1 PIE Vectors
PDPINTA_ISR, // EV-A
PDPINTB_ISR, // EV-B
rsvd_ISR,
XINT1_ISR, 
XINT2_ISR,
ADCINT_ISR, // ADC
TINT0_ISR, // Timer 0
WAKEINT_ISR, // WD
.............
.............
// Group 12 E Vectors
rsvd_ISR, 
rsvd_ISR, 
rsvd_ISR, 
rsvd_ISR, 
rsvd_ISR, 
rsvd_ISR, 
rsvd_ISR, 
rsvd_ISR, 
};
//---------------------------------------------------------------------------
// InitPieVectTable: 
//---------------------------------------------------------------------------
// This function initializes the PIE vector table to a known state.
// This function must be executed after boot time.
//

void InitPieVectTable(void)
{
int16 i;
Uint32 *Source = (void *) &PieVectTableInit;
Uint32 *Dest = (void *) &PieVectTable;

EALLOW; 
for(i=0; i < 128; i++)
*Dest++ = *Source++; 
EDIS;

// Enable the PIE Vector Table
PieCtrl.PIECRTL.bit.ENPIE = 1; 

}
5.中断服务程序:
让以上的数值指向你所要的服务程序,例如:
PieVectTable.TINT2 = &ISRTimer2;
那么,ISRTimer2也就成了中断服务程序,
×××切记:一定要在主程序的开始先声明该程序:
interrupt void ISRTimer2(void);

.............
.............
然后按照您的需要编制该程序:
interrupt void ISRTimer2(void)
{
CpuTimer2.InterruptCount++;
}

分享: