1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
ADN4604芯片用iic读写的时候,会出现数据误码。而且图像通道也不通,不知道问题出在哪。检查了硬件应该没有问题。配置寄存器的时候就是 填写MAP0通道数据,配置通道输出模式(0X30),使能MAP0,updata 相关代码如下:
void IIC_Start(void) { IIC_ADN4604_SDA_OUT; IIC_ADN4604_SDA1; IIC_ADN4604_SCL1; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SDA0; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SCL0; } void IIC_Stop(void) { IIC_ADN4604_SDA_OUT; IIC_ADN4604_SCL0; IIC_ADN4604_SDA0; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SCL1; IIC_ADN4604_SDA1; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); } u8 IIC_Wait_Ack(void) { u8 ucErrtime=0; IIC_ADN4604_SDA_IN; IIC_ADN4604_SDA1;IIC_ADN4604_delay_us(1); IIC_ADN4604_SCL1;IIC_ADN4604_delay_us(1); while(IIC_ADN4604_READ_SDA) { ucErrTime++; if(ucErrTime>250) { IIC_Stop(); return 1; } } IIC_ADN4604_SCL0; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); return 0; } void IIC_Ack(void) { IIC_ADN4604_SCL0; IIC_ADN4604_SDA_OUT; IIC_ADN4604_SDA0; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SCL1; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SCL0; } void IIC_NAck(void) { IIC_ADN4604_SCL0; IIC_ADN4604_SDA_OUT; IIC_ADN4604_SDA1; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SCL1; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SCL0; } void IIC_Send_Byte(u8 txd) { u8 t; IIC_ADN4604_SDA_OUT; IIC_ADN4604_SCL0; for(t=0;t<8;t++) { if((txd&0x80)>>7) IIC_ADN4604_SDA1; else IIC_ADN4604_SDA0; txd<<=1; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SCL1; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SCL0; } } u8 IIC_Read_Byte(unsigned char ack) { unsigned char i,receive=0; IIC_ADN4604_SDA_IN; for(i=0;i<8;i++ ) { IIC_ADN4604_SCL0; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); IIC_ADN4604_SCL1; IIC_ADN4604_delay_us(I2C_ADN4604_Delay); receive<<=1; if(IIC_ADN4604_READ_SDA)receive++; } if (!ack) IIC_NAck(); else IIC_Ack(); return receive; } void I2C_WriteByte(uint8_t device_addr,uint8_t addr,uint8_t data) { IIC_Start(); IIC_Send_Byte(device_addr); IIC_Wait_Ack(); IIC_Send_Byte(addr); IIC_Wait_Ack(); IIC_Send_Byte(data); IIC_Wait_Ack(); IIC_Stop(); Delay_Ms(10); } uint8_t I2C_ReadByte(uint8_t device_addr,uint8_t addr) { uint8_t data; IIC_Start(); IIC_Send_Byte(device_addr); IIC_Wait_Ack(); IIC_Send_Byte(addr); IIC_Wait_Ack(); IIC_Start(); IIC_Send_Byte(device_addr|0X01); IIC_Wait_Ack(); data=IIC_Read_Byte(0); IIC_Stop(); return data; } void write(u8 addr,u8 *buffer,u8 num) { while(num--) { I2C_WriteByte(IIC_ADN4604_ADDR,addr,*buffer); addr++; buffer++; } } u8 AD4604_read(u8 addr,u8 *buffer,u8 num) { while(num) { *buffer++=I2C_ReadByte(IIC_ADN4604_ADDR,addr++); num--; } return *buffer; } void ADN4604_Init(void) { unsigned char lianjie[8]={0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55}; IIC_ADN4604_Init_Pin(); write(ADN_XPT_MAP0_CON_REG,lianjie,8); I2C_WriteByte(IIC_ADN4604_ADDR,0x18,0X30); I2C_WriteByte(IIC_ADN4604_ADDR,0x81,0); I2C_WriteByte(IIC_ADN4604_ADDR,0x80,1); } |
|
相关推荐
1个回答
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
RK3588 HDMI in 接入设备如何获取HDMI in 传入的音频?
1352 浏览 1 评论
23361 浏览 1 评论
1250 浏览 0 评论
硬创大赛项目专访 | 田奕鑫:专注细分领域创新,我们和行业巨头“化敌为友”
94616 浏览 1 评论
硬创大赛项目专访 | 王猛:专研降噪技术,让中国的黑科技产品服务全球用户
24459 浏览 1 评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 07:30 , Processed in 0.689881 second(s), Total 107, Slave 87 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号