DSP 101102

来源:互联网 发布:哪些淘宝店铺适合学生 编辑:程序博客网 时间:2024/05/01 14:19

"extern cregister volatile unsigned int IFR;"

 

关键字:
volatile 
易变(C:与const一样,volatile是一个类型修饰符(type specifier)。它是被设计用来修饰被不同线程访问和修改的变量。)
   推荐一个定义为volatile的变量是说这变量可能会被意想不到地改变,这样,编译器就不会去假设这个变量的值了。精确地说就是,优化器在用到这个变量时必须每次都小心地重新读取这个变量的值,而不是使用 保存在寄存器里的备份 。

  volatile定义的变量和不是用volatile定义的变量区别在于你的程序在编译的时候,如果编译器认为这个变量在一段时间内不会被调用,那么不用volatile定义的变量会被编译器cut,从而节省内存.volatile定义的变量则编译器不会把它cut.因为很多编译器有时都会"自作聪明"的帮你cut暂时不用的变量,所以重要的变量最好是用volaitile来定义.

cregister
这两个寄存器是可以用关键字cregister定义的寄存器,定义之后就可以直接调用了。然后在相应的c源代码中直接引用这些变量了。ps:why?101102. - 3idiots - san_idiots的博客

官方解释哈哈: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.

 

Q1:为什么 

struct PIEIFR_BITS {     // bits description
   Uint16 INTx1:1;         // 0    INTx.1
   Uint16 INTx2:1;         // 1    INTx.2
   Uint16 INTx3:1;         // 2    INTx.3
   Uint16 INTx4:1;         // 3    INTx.4
   Uint16 INTx5:1;         // 4    INTx.5
   Uint16 INTx6:1;         // 5    INTx.6
   Uint16 INTx7:1;         // 6    INTx.7
   Uint16 INTx8:1;         // 7    INTx.8
   Uint16 rsvd:8;          // 15:8 reserved
};

有些给1位,有些却给3位??