现在卡在g-sensor驱动这边,驱动现在没有打开中断,只是在静止的状态下读取mma7660fc的寄存器值。但读取的值都是错
的。以下是读取出来的寄存器的值,我只读取了0x00,0x01,0x02和0x03寄存器。(0x00--x; 0x01--y; 0x02--z; 0x03--tilt)
tcc_sensor_get_accel: x:3, y:4, z:4, tilt: 4
----------
tcc_sensor_get_accel: x:2, y:2, z:2, tilt: 3
----------
tcc_sensor_get_accel: x:3, y:2, z:2, tilt: 2
----------
tcc_sensor_get_accel: x:4, y:4, z:4, tilt: 3
----------
tcc_sensor_get_accel: x:4, y:4, z:4, tilt: 4
----------
tcc_sensor_get_accel: x:3, y:3, z:3, tilt: 3
----------
tcc_sensor_get_accel: x:2, y:2, z:2, tilt: 2
----------
tcc_sensor_get_accel: x:3, y:3, z:1, tilt: 1
正常情况下应该(0,0,42/43)。。首先Mma7660这个设备是在active模式的,否则读取的REGS都是0。
还有一个奇怪的现象是,对mma7660寄存器0x07写入一个值,在读取出来的值也不一样
初始化源代码:
void MMA7660_MIN_MODE_Startup(void)
{
MMA7660_PDET_Value = 0xE0;
MMA7660_MODE_Value = 0x01;
MMA7660_Init();
}
static void MMA7660_Init(void)
{
SENSOR_SEND_CMD(MMA7660_MODE, 0x0); //Make 7660 enter standby mode to set registers
SENSOR_SEND_CMD(MMA7660_SPCNT, MMA7660_SPCNT_Value);
SENSOR_SEND_CMD(MMA7660_INTSU, MMA7660_INTSU_Value);
SENSOR_SEND_CMD(MMA7660_SR, MMA7660_SR_Value);
SENSOR_SEND_CMD(MMA7660_PDET, MMA7660_PDET_Value);
SENSOR_SEND_CMD(MMA7660_PD, MMA7660_PD_Value);
SENSOR_SEND_CMD(MMA7660_MODE, MMA7660_MODE_Value);
}
//未被赋值的MMA7660_SPCNT_Value、MMA7660_INTSU_Value、MMA7660_INTSU_Value、MMA7660_PD_Value都为0
望高手赐教。。。
5 个解决方案
#1
你的G-Sensor是数字输出还是模拟输出的. 如果是模拟输出的直接读x.y.z的模拟信号即可. 数字就的是I2C通讯格式
#2
你好,ZeiGe353300,MMA7660FC代码能发给我一份吗?谢谢
abstttk@126.com
abstttk@126.com
#3
你好
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
#4
你好
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
#5
你好
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
#1
你的G-Sensor是数字输出还是模拟输出的. 如果是模拟输出的直接读x.y.z的模拟信号即可. 数字就的是I2C通讯格式
#2
你好,ZeiGe353300,MMA7660FC代码能发给我一份吗?谢谢
abstttk@126.com
abstttk@126.com
#3
你好
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
#4
你好
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
#5
你好
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了
初始化代码如下
mma7660_i2c_write_byte(client,mma7660_mode,0x00);
mma7660_i2c_write_byte(client,mma7660_spcnt,0x00);
mma7660_i2c_write_byte(client,mma7660_intsu,0x03);
mma7660_i2c_write_byte(client,mma7660_sr, 0x31);
mma7660_i2c_write_byte(client,mma7660_pdet,0xe0);
mma7660_i2c_write_byte(client,mma7660_pd,0x00);
mma7660_i2c_write_byte(client,mma7660_mode,0x41);
但是我也有个问题想不通,你说的正常情况下应该(0,0,42/43)。。这个怎么换算成加速度啊 ,因为你正常放在桌面上重力加速度应该是9.8,这个怎么换算来的,希望指教我的qq 258031823谢谢了