ad7793在stm32下的控制程序谁有,千分悬赏。经验证后付费也可以。

ad7793在stm32下的控制程序谁有,千分悬赏。经验证后付费也可以。,第1张

够详细了吧。。。

void AD7793_GPIO_Config(void){GPIO_InitTypeDef GPIO_InitStructure GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING GPIO_Init(GPIOA, &GPIO_InitStructure) GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_6 | GPIO_Pin_7 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP GPIO_Init(GPIOA, &GPIO_InitStructure) RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE) AD7793_CS_SET() }void WriteToReg(unsigned char ByteData) {unsigned char temp unsigned char i AD7793_CS_CLR() temp=0x80 for(i=0i<8i++){if((temp &ByteData)==0){AD7793_DIN_CLR() }else{AD7793_DIN_SET() }AD7793_SCLK_CLR() Delay(200) AD7793_SCLK_SET() Delay(200) temp=temp>>1 }AD7793_CS_SET()}void AD7793_Reset(void) //复位AD7793{unsigned int ResetTime ResetTime=32 AD7793_SCLK_SET() AD7793_CS_CLR() AD7793_DIN_SET() while(ResetTime--){WriteToReg(0xff) Delay(100) AD7793_SCLK_CLR() Delay(100) AD7793_SCLK_SET() }AD7793_CS_SET()}unsigned char AD7793_ReadStatusRegister(void) //读状态寄存器{unsigned char j unsigned char temp WriteToReg(0x40) AD7793_DIN_SET() AD7793_CS_CLR() temp=0 AD7793_DOUT_SET()for(j=0j<8j++){AD7793_SCLK_CLR() AD7793_DOUT_SET()if(AD7793_DOUT_GET()==0){temp=temp<<1 }else{temp=temp<<1 temp=temp+0x01 }Delay(200) AD7793_SCLK_SET() Delay(200) }AD7793_CS_SET() return temp}void Ad7793_WriteModeRegister(unsigned char ModeRegisterH,unsigned char ModeRegisterL) //写模式寄存器{WriteToReg(0x08) WriteToReg(ModeRegisterH) WriteToReg(ModeRegisterL)}void Ad7793_WriteConfigRegister(unsigned char ConfigRegisterH,unsigned char ConfigRegisterL) //写配置寄存器{WriteToReg(0x10)WriteToReg(ConfigRegisterH)WriteToReg(ConfigRegisterL)}void Ad7793_WriteIORegister(unsigned char IORegister) //写IO寄存器{WriteToReg(0x28)WriteToReg(IORegister)}long AD7793_ReadDataRegister(void) //读数据寄存器{union long_4uchar AD7793Result unsigned char i,j unsigned char temp temp=AD7793_ReadStatusRegister() while((temp&0x80)==0x80){temp=AD7793_ReadStatusRegister() }WriteToReg(0x58) AD7793_DIN_SET() AD7793_CS_CLR()AD7793_DOUT_SET()for(i=0i<3i++){for(j=0j<8j++){AD7793_SCLK_CLR() AD7793_DOUT_SET()if(AD7793_DOUT_GET()==0){temp=temp<<1 }else{temp=temp<<1 temp=temp+0x01 }Delay(200) AD7793_SCLK_SET() Delay(200) }AD7793Result._4byte._uchar[3-i]=temp }AD7793_CS_SET() AD7793Result._long=AD7793Result._long>>17 return AD7793Result._long}void Init_AD7793(void){AD7793_GPIO_Config() AD7793_Reset() Ad7793_WriteModeRegister(0x00,0x0a) Ad7793_WriteConfigRegister(0x1A,0x10) Ad7793_WriteIORegister(0x03)}

额定功率在400W够了,主要是品牌选择,市场很多杂牌电源,功率上都虚标严重,推荐首选1:航嘉电源,2:长城电源,就行了,

需要正规专卖店购买,这些市场也是有山寨,第一感觉判断,用手衡量重量,看线的硬软程度,电源整体外观做工细腻感,自己把握吧…


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12133835.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存