Board logo

标题: [求助]又是ECT中断问题,SOS…… [打印本页]

作者: chenkaijiang200    时间: 2007-7-7 18:01     标题: [求助]又是ECT中断问题,SOS……

高人们,帮我看看吧,为什么没有产生中断:
main.c文件:
#include /* common defines and macros */
#include /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
unsigned int time,count=0;
//time为小轮一圈的时间1表示0.0013653s 一圈4cm
unsigned int lasttime=0,thistime;
//lasttime为上次的计数器值,thistime为此次的计数器值
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 51 TIME4_ISR(void);
void interrupt 47 TIMEOF_ISR(void);
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 51 TIME4_ISR(void)
{
TFLG1_C4F = 1 ; //清中断标志位
//EnableInterrupts;
thistime=TC4;

time=count*4096+(thistime-lasttime)/16;
count=0;

/*if(thistime>lasttime)
time=thistime-lasttime;
else
time=0xffff-lasttime+thistime;
*/
//lasttime=thistime;
}
void interrupt 47 TIMEOF_ISR(void)
{
TFLG2_TOF = 1; //清定时器溢出标志位
count++;
}
void main()
{
PWMPOL=0XFF; //设置PWM脉冲以上升延开始
PWMCLK=0X20; //设置CLOCK SA作为PWM的时钟源
PWMPRCLK=0x04; //设置CLOCK A频率为bus clock/128
PWMCAE=0;
PWMSCLA=0x05; //设置CLOCK SA的频率
PWMSCLB=0;

PWMCTL=0;

PWMCNT5=0;
PWMPER5=0XFF; //设置PWM周期
PWMDTY5=0X7f; //设置PWM占空比
PWME=0XFF;
PWME_PWME5=1;

EnableInterrupts;
TIOS=0X00;
TSCR2=0X90;//
TCTL3=0X01;
TIE=0X10;//ENABLE INTERRUPT
DDRA=0x00;
while(1)
{

//PORTA=time;
}
}

prm文件:
/* This is a linker parameter file for the MC9S12DG128 */
NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */

SEGMENTS /* here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
RAM = READ_WRITE 0x0400 TO 0x1FFF;
/* unbanked FLASH ROM */
ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF;
ROM_C000 = READ_ONLY 0xC000 TO 0xFEFF;
/* banked FLASH ROM */
PAGE_38 = READ_ONLY 0x388000 TO 0x38BFFF;
PAGE_39 = READ_ONLY 0x398000 TO 0x39BFFF;
PAGE_3A = READ_ONLY 0x3A8000 TO 0x3ABFFF;
PAGE_3B = READ_ONLY 0x3B8000 TO 0x3BBFFF;
PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
/* PAGE_3E = READ_ONLY 0x3E8000 TO 0x3EBFFF; not used: equivalent to ROM_4000 */
/* PAGE_3F = READ_ONLY 0x3F8000 TO 0x3FBFFF; not used: equivalent to ROM_C000 */
END

PLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. */
_PRESTART, /* Used in HIWARE format: jump to _Startup at the code start */
STARTUP, /* startup data structures */
ROM_VAR, /* constant variables */
STRINGS, /* string literals */
VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */
//.ostext, /* OSEK */
NON_BANKED, /* runtime routines which must not be banked */
COPY /* copy down information: how to initialize variables */
/* in case you want to use ROM_4000 here as well, make sure
that all files (incl. library files) are compiled with the
option: -OnB=b */
INTO ROM_C000/*, ROM_4000*/;
DEFAULT_ROM INTO PAGE_38,PAGE_39,PAGE_3A,PAGE_3B,PAGE_3C,PAGE_3D;

//.stackstart, /* eventually used for OSEK kernel awareness: Main-Stack Start */
SSTACK, /* allocate stack first to avoid overwriting variables on overflow */
//.stackend, /* eventually used for OSEK kernel awareness: Main-Stack End */
DEFAULT_RAM INTO RAM;
//.vectors INTO OSVECTORS; /* OSEK */
END

ENTRIES /* keep the following unreferenced variables */
/* OSEK: always allocate the vector table and all dependent objects */
//_vectab OsBuildNumber _OsOrtiStackStart _OsOrtiStart
END

STACKSIZE 0x100

VECTOR 0_Startup /* reset vector: this is the default entry point for a C/C++ application. */
//VECTOR 0 Entry /* reset vector: this is the default entry point for an Assembly application. */
//INIT Entry /* for assembly applications: that this is as well the initialization entry point */
//
VECTOR ADDRESS 0XFFDE TIMEOF_ISR
VECTOR ADDRESS 0XFFE6 TIME4_ISR


先谢过了啊!
作者: chenkaijiang200    时间: 2007-7-7 18:02

我是用PT4捕捉PWM波,作捕捉实验。
作者: malyyuer    时间: 2007-7-7 21:10

你在main文件中用interrupt+中断号声明了,就不用在PRM文件中加
VECTOR ADDRESS 0XFFDE TIMEOF_ISR
VECTOR ADDRESS 0XFFE6 TIME4_ISR
另外,输入捕捉的中断号对么?我用的DG128A不是这个。

作者: chenkaijiang200    时间: 2007-7-8 19:26

多谢啦!我也是刚刚接触这款单片机,不太知道中断怎么用。我用的是DG128B,我想中断号应该跟128A一样吧,你用的中断号是多少呢?在DATA SHEET中能查到吗?
作者: ikvc-7    时间: 2007-7-8 22:52

PT4的中断号是   VECTOR ADDRESS 0xEFE6   IOC4_ISR
作者: ikvc-7    时间: 2007-7-8 22:54

忘了说,那是在MCU中有监控程序的情况下,如果没有监控程序
中断号为 VECTOR ADDRESS 0xFFE6 IOC4_ISR
作者: malyyuer    时间: 2007-7-9 10:15

$FFEE, $FFEF Timer channel 0 I bit TMSK1 (C0I) $EE 8号
$FFEC, $FFED Timer channel 1 I bit TMSK1 (C1I) $EC 9号
$FFEA, $FFEB Timer channel 2 I bit TMSK1 (C2I) $EA ..
$FFE8, $FFE9 Timer channel 3 I bit TMSK1 (C3I) $E8 ..
$FFE6, $FFE7 Timer channel 4 I bit TMSK1 (C4I) $E6 ..
$FFE4, $FFE5 Timer channel 5 I bit TMSK1 (C5I) $E4 ..
$FFE2, $FFE3 Timer channel 6 I bit TMSK1 (C6I) $E2 ..
$FFE0, $FFE1 Timer channel 7 I bit TMSK1 (C7I) $E0 ..
$FFDE, $FFDF Timer overflow I bit TMSK2 (TOI) $DE 16号
作者: chenkaijiang200    时间: 2007-7-9 18:25

感谢!收获太多了!这里真是个好地方啊!
作者: chenkaijiang200    时间: 2007-7-9 18:34

对了,楼上说的不是中断号吧?应该是中断入口地址吧?中断号是void interrupt 51 TIME4_ISR(void)中的51吗?不知道我理解得正不正确呢?

作者: strongchen    时间: 2007-7-10 10:50

这两种定义方法都是可以的,用中断号或用中断地址。但二者不可重复使用。
作者: chenkaijiang200    时间: 2007-7-14 08:59

哦,多谢!




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0