打印
[AVR单片机]

哪位大哥能帮小弟指点?我想把它转换成16位该怎样操作

[复制链接]
988|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
chunzhu|  楼主 | 2008-2-19 15:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
void Write8Bit(uchar input) 
    {
    uchar temp;
    for(temp=8;temp!=0;temp--) 
        {
    SDA=(bit)(input&0x80);////*强制转换8位
        SCL=1;
        SCL=0;
        input=input<<1;
        }
    }
这是对24C02写的指令,假如input==0x3a,我想把它转换成16位该怎样操作?

相关帖子

沙发
stycx| | 2008-2-20 14:30 | 只看该作者

SDA=(bit)(input&0x80);////*强制转换8位 这注解有错吧

应该是是取其高位并转为bit类型


input==0x3a只是8位呀
转为16位? 
input==0x003a ??

使用特权

评论回复
板凳
hzuser| | 2008-2-27 21:25 | 只看该作者

LZ没说清吧?

LZ的例子是操作8位的,如果真要传送16位的,
void Write8Bit(uchar input) //uchar 改为uint
    {
    uchar temp;
    for(temp=8;temp!=0;temp--) //循环8次改为循环16次就行了
        {
    SDA=(bit)(input&0x80);////*强制转换8位??????注释错误
        SCL=1;
        SCL=0;
        input=input<<1;
        }

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

6

帖子

0

粉丝