寄存器位定义时为什么用uint16而不是bit

[复制链接]
5076|5
 楼主| tiger2010 发表于 2010-3-11 12:27 | 显示全部楼层 |阅读模式
在2812的.h文件中 如
     struct  TCR_BITS {        // bits  description
   Uint16    OUTSTS:1;      // 0     Current state of TOUT
   Uint16    FORCE:1;       // 1     Force TOUT
   Uint16    POL:1;         // 2     Output polarity
   Uint16    TOG:1;         // 3     Output toggle mode
   Uint16    TSS:1;         // 4     Timer Start/Stop
   Uint16    TRB:1;         // 5     Timer reload
   Uint16    FRCEN:1;       // 6     Force enable
   Uint16    PWIDTH:3;      // 9:7   BitTOUT output pulse width
   Uint16    SOFT:1;        // 10    Emulation modes
   Uint16    FREE:1;        // 11
   Uint16    rsvd:2;        // 12:13 reserved
   Uint16    TIE:1;         // 14    Output enable
   Uint16    TIF:1;         // 15    Interrupt flag
};
其中FORCE明明是一位,其数据类型为什么不用BIT,而用UINT16
寂寞男孩 发表于 2010-3-11 12:40 | 显示全部楼层
DSP中没有BIT数据类型吧
linhai1986 发表于 2010-3-11 13:06 | 显示全部楼层
这种定义是采用位区的定义方式,这种方式的定义方法有以下有点:
1:可读性强,易于升级
2:可以充分利用Code Composer Studio编辑器的自动代码输入功能。
3:方便Watch窗口观察位变量
thf2008 发表于 2010-3-12 12:18 | 显示全部楼层
这是C语言的 位域定义方式,整个结构体只是一个Uint16类型
liliang9554 发表于 2010-3-12 20:19 | 显示全部楼层
学习了
 楼主| tiger2010 发表于 2010-3-12 23:15 | 显示全部楼层
明白了谢谢楼上两位
您需要登录后才可以回帖 登录 | 注册

本版积分规则

32

主题

338

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部