在线时间0 小时
UID367948
注册时间2012-7-3
NXP金币0
该用户从未签到
新手上路

- 积分
- 180
- 最后登录
- 1970-1-1
|
一:在main.c中把某个中断事件指向Xgate;
二:在xgate.cxgate中创建中断函数;
三:在xgate.cxgate中设置这个中断的向量表;
以PIT0为例,具体操作如下:
使用mc9s12xdt512芯片和codewarrior4.7
---------------------以下在main.c中------------------------- -- -----
#define SOFTWARETRIGGER0_VEC 0x72 /* vector address= 2 * channel id */
// ①: Config PIT channel 0 interrupt register: define vector number
#define PIT_CH0_VEC 0x7A
static void SetupXGATE(void) {
/* initialize the XGATE vector block and
set the XGVBR register to its start address */
XGVBR= (unsigned int)(void*__far)(XGATE_VectorTable - XGATE_VECTOR_OFFSET);
/* switch software trigger 0 interrupt to XGATE */
ROUTE_INTERRUPT(SOFTWARETRIGGER0_VEC, 0x81); /* RQST=1 and PRIO=1 */
// ②: Config PIT channel 0 interrupt register
ROUTE_INTERRUPT(PIT_CH0_VEC, 0x81); // RQST=1: route PIT_ch0 to XGATE; PRIO=1: priority = 1
/* enable XGATE mode and interrupts */
XGMCTL= 0xFBC1; /* XGE | XGFRZ | XGIE */
/* force execution of software trigger 0 handler */
XGSWT= 0x0101;
}
③在main(void)中初始化PIT,xgate(codewarrior自动生成)
-------------------以下在xgate.cxgate-------------------------------
④加入#include "mc9s12xdt512.h" 头文件
// ⑤: define a digit
unsigned char digit=0;
// ⑥: PIT channel 0 thread on XGATE
interrupt void PIT_CH0_Handler(unsigned int dummy)
{ char asd;
PITTF |= 0x01; // wrire 1 to clear the channel 0 time out flag
asd =digit;
digit++;
<span lang="EN-US" style="font-size: 10.5pt; color: red; font-family: "Arial Unicode MS""> PORTB = asd
|
|