查看: 2529|回复: 1

[其他] 使用Xgate三步法

[复制链接]

该用户从未签到

17

主题

70

帖子

0

新手上路

Rank: 1

积分
180
最后登录
1970-1-1
发表于 2012-7-3 14:32:36 | 显示全部楼层 |阅读模式
一:在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
我知道答案 目前已有0人回答
回复

使用道具 举报

该用户从未签到

17

主题

70

帖子

0

新手上路

Rank: 1

积分
180
最后登录
1970-1-1
 楼主| 发表于 2012-7-3 14:33:23 | 显示全部楼层

RE:使用Xgate三步法

目前正在学习xgate,就找到了这些资料,希望大家能提供更多的资料,谢谢了啊!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2025-9-13 03:12 , Processed in 0.090159 second(s), 22 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表