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. Ifthe 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源代码中直接引用这些变量了。
在ti的文档《TMS320C6000 Optimizing Compiler User's Guide》中第188页中有介绍的。你可以先定义一个头文件,专门定义这个变量(实际就是相应的寄存器),然后在相应的c源代码中直接引用这些变量了。定义这些变量的方式是:extern cregister volatile unsigned int register;其中register就是AMR,CSR,IFR等寄存器。例如:
extern cregister volatile unsigned int AMR;
extern cregister volatile unsigned int CSR;
extern cregister volatile unsigned int IFR;
extern cregister volatile unsigned int ISR;
extern cregister volatile unsigned int ICR;
extern cregister volatile unsigned int IER;
extern cregister volatile unsigned int FADCR;
extern cregister volatile unsigned int FAUCR;
extern cregister volatile unsigned int FMCR;
main(){printf(”AMR = %x\n”, AMR);}
10#:
感谢分享!不过建议下次在发表新帖时勾选“讨论”,而不要使用默认的“问题’,谢谢!:)