首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

关于Keil-C51中的sbit的一点学习(转)

关于Keil-C51中的sbit的一点学习(转)

1、        官方手册标准说明:The sbit type provides access to bit-addressable SFRs and other bit-addressable objects
2、        sbit只能用于可位寻址SFR,非位可寻址SFR不可用
3、        sbit不仅能够用于SFR,对于可位寻址的一般变量同样可用,如:
bdata char flag;
sbit f_b1 = flag^1
这一特性非常有用,例如:可以将从LCD1602状态寄存器读取到的字节存放于flag变量中,然后状态寄存器的所有状态位可以单独读取、判断。
4、        sbit 变量只能是全局变量,也就是说,sbit变量必须要在函数外声明/定义
5、        最复杂的一个官方“Note”:Storage of objects accessed using sbit is assumed to be little endian (LSB first). This is the storage format of the sfr16 type but it is opposite to the storage of int and long data types. Care must be taken when using sbit to access bits within standard data types.
返回列表