求助关于加速度MMA7455问题
用CVAVR编写MMA7455的程序用自带的I2C.H库
这是分别我定义的两个写和读,按照手册上写的时序.
中间延迟部分我不确定是多少...
芯片地址左移1位后就是0x3a
void mmaw(unsigned int add,unsigned char data)
{
i2c_start();
i2c_write(0x3a);
delay_us(10);
i2c_write(add);
i2c_write(data);
i2c_stop();
}
unsigned int mmar(unsigned int add)
{
i2c_start();
i2c_write(0x3a);
delay_us(10);
i2c_write(add);
i2c_start();
i2c_write(0x3b);
i2cdata=i2c_read(0);
return i2cdata;
}
下面开始用,向0x16寄存器写0x05h和读寄存器Z轴
mmaw(0x16,0x05);
data=mmar(0x06);
因为下面紧接着是LCD显示程序,运行后LCD一直停留,应该是这部分卡住了,,,大神帮我看看哪地方不对?? 我整理的MMA7455L 程序,你参考参考。
I2C通信方式的不太好 ,速度慢,稳定性差。
SPI方式虽然多用两根线,可是稳定性好,所以我一直都用这种方式。网上关于SPI方式的MMA7455L的资料比较难找,这个是我自己参考其它资料写出来的。
页:
[1]