怎么使用codewarrior 里的PE中断

 我来答
xiangjuan314
2016-04-26 · TA获得超过3.3万个赞
知道大有可为答主
回答量:2.9万
采纳率:0%
帮助的人:2929万
展开全部
Defining Interrupt Functions

This manual entry discusses some important topics related to the handling of interrupt functions:

· Definition of an interrupt function

· Initialization of the vector table

· Placing interrupt function in special sections

Defining an Interrupt Function

The compiler provides two ways to define an interrupt function:

· Using pragma TRAP_PROC.

· Using the keyword interrupt.

Using Pragma "TRAP_PROC"

The pragma TRAP_PROC indicates to the compiler that the following function is an interrupt function. In that case, the compiler should terminate the function by a special interrupt return sequence (for many processors a RTI instead of a RTS).

Example:

#pragma TRAP_PROC

void INCcount(void) {

tcount++;

}

Using Keyword "interrupt"

The keyword `interrupt" is not ANSI C standard and as thus is not supported by all ANSI C compiler vendor. In the same way, the syntax for the usage of this keyword may change between different compiler. The keyword interrupt indicates to the compiler that the following function is an interrupt function.

Example:

interrupt void INCcount(void) {

tcount++;

}

Initializing the Vector Table

Once the code for an interrupt function has been written, you have to associate this function with an interrupt vector. This is done through initialization of the vector table. The vector table can be initialized in following ways:

· Using the command VECTOR or VECTOR ADDRESS in the PRM file

· Using the keyword "interrupt".

Using the Linker Commands

The Linker provides two commands to initialize the vector table: VECTOR or VECTOR ADDRESS. The command VECTOR ADDRESS is used to write the address of a function at a specific address in the vector table.

Example:

In order to enter the address of the function INCcount at address 0x8A, insert following command in the application PRM file:

VECTOR ADDRESS 0x8A INCcount

The command VECTOR is used to associate a function with a specific vector, identified with its number. The mapping from the vector number is target specific.

Example:

In order to associate the address of the function INCcount with the vector number 69, insert following command in the application PRM file:

VECTOR ADDRESS 69 INCcount

Using the Keyword "interrupt"

When you are using the keyword "interrupt", you may directly associate your interrupt function with a vector number in the ANSI C source file. In that purpose just specify the vector number next to the keyword interrupt.

Example:

In order to associate the address of the function INCcount with the vector number 69, define your function as follows:

interrupt 69 void INCcount(void) {

int card1;

tcount++;

}

Placing Interrupt Function in Special Sections

For all targets supporting paging, the interrupt function must be allocated in an area which is accessible all the time. This can be obtained by putting the interrupt function into a specific segment.

Defining Functions in a Specific Segment.

In order to define a function in a specific segment, you can use the pragma CODE_SEG.

Example:

/* These functions are defined in segment `int_Function'*/

#pragma CODE_SEG Int_Function

#pragma TRAP_PROC

void INCcount(void) {

tcount++;

}

#pragma CODE_SEG DEFAULT /*Return to default code segment.*/

Placing a Specific Segment.

In the PRM file, you can define where you want to allocate each segments you have defined in your source code. In order to place a segment in a specific memory area; just add the segment name in the PLACEMENT block of your PRM file. Be careful, the linker is case sensitive. Take special attention to the upper and lower cases in your segment name.

Example:

LINK test.abs

NAMES test.o ... END

SECTIONS

INTERRUPT_ROM = READ_ONLY 0x4000 TO 0x5FFF;

MY_RAM = READ_WRITE ....

PLACEMENT

Int_Function INTO INTERRUPT_ROM;

DEFAULT_RAM INTO MY_RAM;

....

END
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式