完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
这是我的程序
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.4frn",((float)((temp1>>11) 0x00000fff)/4096)*4+1); printf("%5.4frn",((float)((temp2>>11) 0x00000fff)/4096)*4+1); printf("%5.4frn",((float)((temp3>>11) 0x00000fff)/4096)*4+1); printf("%5.4frn",((float)((temp4>>11) 0x00000fff)/4096)*4+1); printf("%5.4frn",((float)((temp5>>11) 0x00000fff)/4096)*4+1); printf("%5.4frn",((float)((temp6>>11) 0x00000fff)/4096)*4+1); printf("%5.4frn",((float)((temp11>>11) 0x00000fff)/4096)*5); printf("%5.4frn",((float)((temp22>>11) 0x00000fff)/4096)*5); printf("%5.4frn",((float)((temp33>>11) 0x00000fff)/4096)*5); printf("%5.4frn",((float)((temp44>>11) 0x00000fff)/4096)*5); printf("%5.4frn",((float)((temp55>>11) 0x00000fff)/4096)*5); printf("%5.4frn",((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 电池检测部分的电压值一个都不对 |
|
相关推荐
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
电源板:求助小熊A50M2加湿器电源主板有二个稳压二极管坏了
925 浏览 1 评论
1373 浏览 1 评论
2988 浏览 1 评论
4280 浏览 4 评论
2837 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-22 18:00 , Processed in 0.589322 second(s), Total 72, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号