打印

LDC1314使用求助

[复制链接]
276|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
卡拉瓦乔|  楼主 | 2018-7-17 16:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
使用LDC1314,读的时候一直读到255和5535,不只是数据寄存器,其他寄存器也都是。
用的STM32F407,这是初始化代码。
LDC的7bit地址是什么意思?0x2A 和0x2B ,没太看懂

void LDC1314_Init(void) //³õʼ»¯LDC1314ºÍI2C
{
IIC_Init();       //IIC³õʼ»¯
LDC_ADDR = 0; //LDCµÄ7bitµØַΪ0X2A£¬×¢ÒâÊÇ7bit ¼´ 0101 010_  ×îµÍλΪ¶Áдλ
LDC_SD = 0;  //Í˳öShutdown Mode
delay_ms(500); //ÑÓʱ500ms


LDC_write_16bit(LDC13xx16xx_CMD_REF_COUNT_CH0,0X04D6);

LDC_write_16bit(LDC13xx16xx_CMD_REF_COUNT_CH1,0X04D6);
LDC_write_16bit(LDC13xx16xx_CMD_REF_COUNT_CH2,0X04D6);
LDC_write_16bit(LDC13xx16xx_CMD_REF_COUNT_CH3,0X04D6);

LDC_write_16bit(LDC13xx16xx_CMD_SETTLE_COUNT_CH0,0X000A);
LDC_write_16bit(LDC13xx16xx_CMD_SETTLE_COUNT_CH1,0X000A);
LDC_write_16bit(LDC13xx16xx_CMD_SETTLE_COUNT_CH2,0X000A);
LDC_write_16bit(LDC13xx16xx_CMD_SETTLE_COUNT_CH3,0X000A);

LDC_write_16bit(LDC13xx16xx_CMD_CLOCK_DIVIDERS_CH0,0X1002);
LDC_write_16bit(LDC13xx16xx_CMD_CLOCK_DIVIDERS_CH1,0X1002);
LDC_write_16bit(LDC13xx16xx_CMD_CLOCK_DIVIDERS_CH2,0X1002);
LDC_write_16bit(LDC13xx16xx_CMD_CLOCK_DIVIDERS_CH3,0X1002);

LDC_write_16bit(LDC13xx16xx_CMD_ERROR_CONFIG,0X0000);

LDC_write_16bit(LDC13xx16xx_CMD_MUX_CONFIG,0X0820C);

LDC_write_16bit(LDC13xx16xx_CMD_DRIVE_CURRENT_CH0,0x9000);
LDC_write_16bit(LDC13xx16xx_CMD_DRIVE_CURRENT_CH1,0x9000);
LDC_write_16bit(LDC13xx16xx_CMD_DRIVE_CURRENT_CH2,0x9000);
LDC_write_16bit(LDC13xx16xx_CMD_DRIVE_CURRENT_CH3,0x9000);
LDC_write_16bit(LDC13xx16xx_CMD_CONFIG,0x1601);  //bit13 ÇåÁã Í˳ö˯Ãßģʽ


}

这是读寄存器的代码:
u16 LDC_read_16bit(u8 regaddr)
{
u16 data_temp = 0;
u16 data_temp1 = 0;

IIC_Start();
IIC_Send_Byte(LDC1314_ADDR_WRITE);
IIC_Wait_Ack();
IIC_Send_Byte(regaddr); //¼Ä´æÆ÷µØÖ·
IIC_Wait_Ack();

IIC_Start();
IIC_Send_Byte(LDC1314_ADDR_READ);
IIC_Wait_Ack();
data_temp1 = IIC_Read_Byte(0);
data_temp = IIC_Read_Byte(0);
IIC_Stop();

data_temp = data_temp + (data_temp1<<8) ;
return data_temp;

}

使用特权

评论回复

相关帖子

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

本版积分规则

438

主题

438

帖子

0

粉丝