DSP中关于cregister的使用

看源程序(TMS320F2812)的时候在main函数中看到这样一段:

 // Disable and clear all CPU interrupts:

 DINT;

 IER = 0x0000;

 IFR = 0x0000;

就想看看这个IER和IFR的地址,结果找来找去都找不到,只在Device.h中有这样两段:

extern cregister volatile unsigned int IFR;

extern cregister volatile unsigned int IER;

就感觉很奇怪呀,没有地址怎么操作呀?所以上网查了查,才知道答案了。

在官方资料中(TMS320C28x Optimizing C/C++ Compiler.pdf)中有这样的说明:

The compiler extends the C/C++ language by adding the cregister keyword to allow high level language access to control registers.When you use the cregister keyword on an object, the compiler compares the name of the object to a list of standard control registers for the C28x (see Table 6-2 ). If the name matches, the compiler generates the code to reference the control register. If the name does not match, the compiler issues an error.

Table 6-2. Valid Control Registers

------------------------------------

Register              Description

------------------------------------------

IER Interrupt         enable register

IFR Interrupt         flag register

To use the control registers in Table 6-2 , you must declare each register as follows. The c28x.h include file defines all the control registers through this syntax:

extern cregister volatile unsigned int register ;

原来这两个寄存器是可以用关键字cregister定义的寄存器,定义之后就可以直接调用了。

你可以先定义一个头文件,专门定义这个变量(实际就是相应的寄存器),

然后在相应的c源代码中直接引用这些变量了。

PS:貌似在DSP62XX系列中有更多这样的寄存器AMR,IAR,IER,ICR

你可能感兴趣的:(DSP中关于cregister的使用)