此帖出自模拟电子论坛
最新回复
你好,想请教您关于ADCU7026的硬件I2C读写程序的问题,我用7026读加速度计LIS35DE一直不对,卡死在while((I2C1FSTA & 0x30)!=0x00){},这一步,不知道这个硬件I2C到底怎么用,下面是我的写和读的函数
void I2C_write(unsigned char Sads, unsigned char Dads, int d){
I2C1MTX=Dads;
I2C1ADR=Sads;
while((I2C1FSTA & 0x30)!=0x00){}
I2C1MTX=d;
while((I2C1FSTA & 0x30)!=0x00){}
I2C1CCNT=0x80;
}
void I2C_read(unsigned char Sads,unsigned char Dads)
{
I2C1MTX=Dads;
I2C1ADR=Sads;
while ((I2C1FSTA&0xC0)!=0x00){}
delay(4000);
I2C1CNT=count;
I2C1ADR=Sads+1;
if((I2C0MSTA & 0x8) == 0x8)
{
dat= I2C1MRX;
putchar(0xff);
}
}
希望能帮忙看一下,十分感谢[em:2:]
详情
回复
发表于 2017-5-8 16:32
| ||
|
||
此帖出自模拟电子论坛
| ||
|
||
| |
个人签名http://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr |
|
此帖出自模拟电子论坛
| ||
|
||
EEWorld Datasheet 技术支持