3916|2

11

帖子

0

TA的资源

一粒金砂(中级)

楼主
 

AD7280的问题 [复制链接]

这是我的程序
        u32 spi(u32 data)
        {
                u32 Data_recive;
                u8 temp11,temp22,temp33,temp44;
                u8 temp1,temp2,temp3,temp4;

                temp4=data;
          temp3=data>>8;
          temp2=data>>16;
          temp1=data>>24;
               
               
                AD7280A_NCS;
                _nop_();                                                        //delay >10ns
                delay_us(10);
                SPI_Tx(temp1);
                //delay_us(2);                                                //need longer wait while reading single chip at upper position
                temp11=SPI_Rx();
                SPI_Tx(temp2);
                //delay_us(2);                                                //need longer wait while reading single chip at upper position
                temp22=SPI_Rx();
                SPI_Tx(temp3);
                //delay_us(2);                                                //need longer wait while reading single chip at upper position
                temp33=SPI_Rx();
                SPI_Tx(temp4);
                //delay_us(2);                                                //need longer wait while reading single chip at upper position
                temp44=SPI_Rx();
                delay_us(10);
                AD7280A_CS;
                delay_us(3);
                Data_recive=(temp11<<24)+(temp22<<16)+(temp33<<8)+temp44;
                printf("%x %x %x %x ",temp11,temp22,temp33,temp44);

                return Data_recive;
        }
                void initad7280_1()
        {
                spi(0x01c2b6e2);
                delay_us(90);
                AD7280A_NCS;
                delay_us(15);
                AD7280A_CS;
                spi(0x038716ca);
  }
                void caiji_1()
                {
                        u32 temp1,temp2,temp3,temp4,temp5,temp6;
                        u32 temp11,temp22,temp33,temp44,temp55,temp66;
                       

                        spi(0x038011CA);
                        spi(0x01A0131A);
                        delay_us(90);//90us
                        spi(0x03A0546A);
               

                        AD7280A_CNVST;
                        delay_us(10); //CNVST
                        AD7280A_NCNVST;
                        delay_us(50);
                       
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;   
                       
                        temp1=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

       
                        temp2=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

                        temp3=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

                        temp4=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

                        temp5=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

                        temp6=spi(0xF800030A);
                        delay_us(90);//90us
                       
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;
                       
                        temp11=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

       
                        temp22=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

                        temp33=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

                        temp44=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

                        temp55=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;
                        delay_us(10); //CS
                        AD7280A_NCS;

                        temp66=spi(0xF800030A);
                        delay_us(90);//90us
                        AD7280A_CS;



                        printf("%5.4f\r\n",((float)((temp1>>11)&0x00000fff)/4096)*4+1);
                        printf("%5.4f\r\n",((float)((temp2>>11)&0x00000fff)/4096)*4+1);
                        printf("%5.4f\r\n",((float)((temp3>>11)&0x00000fff)/4096)*4+1);
                        printf("%5.4f\r\n",((float)((temp4>>11)&0x00000fff)/4096)*4+1);
                        printf("%5.4f\r\n",((float)((temp5>>11)&0x00000fff)/4096)*4+1);
                        printf("%5.4f\r\n",((float)((temp6>>11)&0x00000fff)/4096)*4+1);       
                       
                        printf("%5.4f\r\n",((float)((temp11>>11)&0x00000fff)/4096)*5);
                        printf("%5.4f\r\n",((float)((temp22>>11)&0x00000fff)/4096)*5);
                        printf("%5.4f\r\n",((float)((temp33>>11)&0x00000fff)/4096)*5);
                        printf("%5.4f\r\n",((float)((temp44>>11)&0x00000fff)/4096)*5);
                        printf("%5.4f\r\n",((float)((temp55>>11)&0x00000fff)/4096)*5);
                        printf("%5.4f\r\n",((float)((temp66>>11)&0x00000fff)/4096)*5);       


但是结果如下
1.0000
1.2227

1.0039

1.0000

1.2510

1.4072

2.1570

2.1936

2.1436

2.1362

2.1228

2.1973

电池检测部分的电压值一个都不对

最新回复

本帖最后由 wangfuchong 于 2015-10-5 15:00 编辑 没情绪仔细看 天烦伊 temp3=data>>8;           temp2=data>>16;           temp1=data>>24; 8比特,怎么能有移大了?  详情 回复 发表于 2015-10-5 14:53
点赞 关注
 
 

回复
举报

5276

帖子

5

TA的资源

裸片初长成(中级)

沙发
 
本帖最后由 wangfuchong 于 2015-10-5 15:00 编辑

没情绪仔细看

天烦伊

temp3=data>>8;
          temp2=data>>16;
          temp1=data>>24;
8比特,怎么能有移大了?
个人签名没工作,没女人老婆,没宽带 ,  没钱
 
 
 

回复

11

帖子

0

TA的资源

一粒金砂(中级)

板凳
 
wangfuchong 发表于 2015-10-5 14:53
没情绪仔细看

天烦伊

temp3=data>>8;
          temp2=data>>16;
          temp1=data>>24;
8bit ...

我在后面加了&0xff结果还是一样的,因为temp是八位的所以默认取低八位
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/8 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表