The cregister Keyword

来源:互联网 发布:中银淘宝校园卡有效期 编辑:程序博客网 时间:2024/05/18 03:37

6.5.2 The cregister Keyword
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 C6000 (see Table 6-3). 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-3. Valid Control Registers===================
Register Description
AMR Addressing mode register
CSR Control status register
DESR (C6700+ only) dMAX event status register
DETR (C6700+ only) dMAX event trigger register
DNUM (C6400+ only) DSP core number register
ECR (C6400+ only) Exception clear register
EFR (C6400+ only) Exception flag register
FADCR (C6700 only) Floating-point adder configuration register
FAUCR (C6700 only) Floating-point auxiliary configuration register
FMCR (C6700 only) Floating-point multiplier configuration register
GFPGFR (C6400 only) Galois field polynomial generator function register
GPLYA (C6400+ only) GMPY A-side polynomial register
CPLYB (C6400+ only) GMPY B-side polynomial register
ICR Interrupt clear register
IER Interrupt enable register
IERR (C6400+ only) Internal exception report register

IFR Interrupt flag register. (IFR is read only.)
ILC (C6400+ only) Inner loop count register
IRP Interrupt return pointer
ISR Interrupt set register
ISTP Interrupt service table pointer
ITSR (C6400+ only) Interrupt task state register
NRP Nonmaskable interrupt return pointer
NTSR (C6400+ only) NMI/exception task state register
REP (C6400+ only) Restricted entry point address register
RILC (C6400+ only) Reload inner loop count register
SSR (C6400+ only) Saturation status register
TSCH (C6400+ only) Time-stamp counter (high 32) register
TSCL (C6400+ only) Time-stamp counter (low 32) register
TSR (C6400+ only) Task state register

===============================================================

The cregister keyword can be used only in file scope. The cregister keyword is not allowed on any declaration within the boundaries of a function. It can only be used on objects of type integer or pointer.The cregister keyword is not allowed on objects of any floating-point type or on any structure or union objects.
The cregister keyword does not imply that the object is volatile. If the control register being referenced is volatile (that is, can be modified by some external control), then the object must be declared with the volatile keyword also.
To use the control registers in Table 6-3, you must declare each register as follows. The c6x.h include file defines all the control registers through this syntax:
extern cregister volatile unsigned int register ;
Once you have declared the register, you can use the register name directly. See the TMS320C62x DSP CPU and Instruction Set Reference Guide, TMS320C64x/C64x+ DSP CPU and Instruction Set Reference Guide, the TMS320C67x/C67x+ DSP CPU and Instruction Set Reference Guide, or TMS320C66x+ DSP CPU and Instruction Set Reference Guide for detailed information on the control registers.See Example 6-1 for an example that declares and uses control registers.

Example 6-1. Define and Use Control Registers
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);
}
0 0
原创粉丝点击