Board logo

标题: 中断没在prm里定义怎么用 [打印本页]

作者: Tom-FS    时间: 2005-8-18 22:30     标题: 中断没在prm里定义怎么用

一边写,一边瞧example,发现一中断:
#ifdef   PCMASTER_INTERRUPT_COMMUNICATION

interrupt PCMASTER_SCI_RXTX_INT_VECTOR void PCMasterRxTxIsr(void){
}
#endif
假如此中断要使用而在prm中未定义,怎么写代码呀
作者: 8808beter    时间: 2005-8-19 08:54

不用管PRM中是否有定义,直接在C中写
interrupt 9 void PCMasterRxTxIsr(void){}
“9”:在中断向量表中查。对应不同的中断和不同的芯片有不同的中断号,如复位的为0(最高级)。
作者: chnnhc    时间: 2005-8-22 21:41

楼上的用法好像是8051的C编程,原来可以这样用,张知识了
作者: sweator    时间: 2005-8-23 12:40

那用寄存器设置成优先级最高后,中断号用改不?
作者: strongchen    时间: 2005-8-23 14:32

中断号只对应于中断矢量地址的物理顺序。

另外,飞思卡尔MCU的中断级别一般也不能更改。
作者: monsterchp    时间: 2005-9-2 12:54

版主,中断级不能改的吗?
没记错的话56800E的中断级别是可以改的,倒是HCS12的好像不能改!
作者: nishui_2000    时间: 2005-9-2 13:16

中断级可以改,但只能改一个中断的优先级。通过一个寄存器设置。
作者: lotte521    时间: 2005-9-3 00:00

H256中断向量表去哪里找?
另外我看到例子里在prm中要设置中断向量表
VECTOR ADDRESS 0xFFEE Timer0

?
是这么用吗?
作者: strongchen    时间: 2005-9-5 10:05

9S12H256BDGV1.pdf的第79页。

关于中断的定义方法,可以参见CodeWarrior自带的Technical Notes: TN101. 这个文档也可以到MetroWerks网站上下载。
作者: lotte521    时间: 2005-9-5 12:30

谢谢斑竹!
作者: lotte521    时间: 2005-9-5 14:30

/* This is a linker parameter file for the MC9S12H256 */
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 0x1000 TO 0x3FFF;
    /* unbanked FLASH ROM */
    ROM_4000 = READ_ONLY  0x4000 TO 0x7FFF;
    ROM_C000 = READ_ONLY  0xC000 TO 0xFEFF;
    /* banked FLASH ROM */
    PAGE_30 = READ_ONLY  0x308000 TO 0x30BFFF;
    PAGE_31 = READ_ONLY  0x318000 TO 0x31BFFF;
    PAGE_32 = READ_ONLY  0x328000 TO 0x32BFFF;
    PAGE_33 = READ_ONLY  0x338000 TO 0x33BFFF;
    PAGE_34 = READ_ONLY  0x348000 TO 0x34BFFF;
    PAGE_35 = READ_ONLY  0x358000 TO 0x35BFFF;
    PAGE_36 = READ_ONLY  0x368000 TO 0x36BFFF;
    PAGE_37 = READ_ONLY  0x378000 TO 0x37BFFF;
    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 */
    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_30,PAGE_31,PAGE_32,PAGE_33,PAGE_34,PAGE_35,PAGE_36,PAGE_37,
                                       PAGE_38,PAGE_39,PAGE_3A,PAGE_3B,PAGE_3C,PAGE_3D;
    DEFAULT_RAM                  INTO  RAM;
END

STACKSIZE 0x100

//VECTOR 0 _Startup /* reset vector: this is the default entry point for a C/C++ application. */
//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 a Assembly application. */
//INIT Entry      /* for assembly applications: that this is as well the initialisation entry point *
VECTOR ADDRESS 0xFFFE          _Startup
VECTOR ADDRESS 0xFFEE Timer0


//Timer.c
#pragma TRAP_PROC
void Timer0(void)
{
         
        TC0 = TC0 + 0xFA00;
   
        //应用程序

        TFLG1=0x1;                  //clear interrupt flag
}


编译后提示
Link Error   : L1108: Initializing of Vector Timer0 failed because of over- or underflow of vector value
作者: strongchen    时间: 2005-9-6 10:39

在中断函数前加一句试试:

#pragma CODE_SEG __NEAR_SEG NON_BANKED




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