AnsweredAssumed Answered

ADXL345 单击中断

Question asked by zzg12 on Jan 22, 2017
Latest reply on Mar 16, 2018 by jwang

你好:

    使用贵司的ADXL345作为单击触发中断信号源,I2C接口,通讯速率25赫兹,配置寄存器后中断不稳定,或者无中断产生,或者中断持续产生,以下为我的寄存器地址及数据配置信息,请收到信息后尽快回复,谢谢。

TARGET = SLAVE_ADDR;
//速率设定 25hz
SMB_DATA_OUT_ADR=0x2c;
SMB_DATA_OUT=0x08;
SMB_Write();
T0_Wait_ms(50);
//电源设置
SMB_DATA_OUT_ADR=0x2D;
SMB_DATA_OUT=0x08;
SMB_Write();
T0_Wait_ms(50);
//中断关闭
SMB_DATA_OUT_ADR=0x2e;
SMB_DATA_OUT=0x00;
SMB_Write();
T0_Wait_ms(50);
//中断配置 sibgletap to int1 pin,0122
SMB_DATA_OUT_ADR=0x2f;
SMB_DATA_OUT=0xBf;
SMB_Write();
T0_Wait_ms(50);
//直流耦合模式,xyz三轴使能
SMB_DATA_OUT_ADR=0x27;
SMB_DATA_OUT=0x70;
SMB_Write();
T0_Wait_ms(50);
//敲击阈值 lsb/255*scale
SMB_DATA_OUT_ADR=0x1d;
SMB_DATA_OUT=0x05;
SMB_Write();
T0_Wait_ms(50);

//敲击检测时间 3ms 1lsb=625us
SMB_DATA_OUT_ADR=0x21;
SMB_DATA_OUT=0x05;
SMB_Write();
T0_Wait_ms(50);
//敲击延迟 delay after tap,1lsb=1250us
SMB_DATA_OUT_ADR=0x22;
SMB_DATA_OUT=0x02;
SMB_Write();
T0_Wait_ms(50);
//window时间 for second tap delay,1lsb=1250us
SMB_DATA_OUT_ADR=0x23;
SMB_DATA_OUT=0x02;
SMB_Write();
T0_Wait_ms(50);
//活动动作阈值 lsb/255*scale
SMB_DATA_OUT_ADR=0x24;
SMB_DATA_OUT=0x10;
SMB_Write();
T0_Wait_ms(50);
//非活动动作阈值 lsb/255*scale
SMB_DATA_OUT_ADR=0x25;
SMB_DATA_OUT=0x02;
SMB_Write();
T0_Wait_ms(50);
//非活动检测时间设置 lsb=1 second
SMB_DATA_OUT_ADR=0x25;
SMB_DATA_OUT=0x05;
SMB_Write();
T0_Wait_ms(50);
//xyz轴 均参与诊断检测
SMB_DATA_OUT_ADR=0x2A;
SMB_DATA_OUT=0x07;
SMB_Write();
T0_Wait_ms(50);
//x轴偏移量
SMB_DATA_OUT_ADR=0x1e;
SMB_DATA_OUT=0x00;
SMB_Write();
T0_Wait_ms(50);
//y轴偏移量
SMB_DATA_OUT_ADR=0x1f;
SMB_DATA_OUT=0x00;
SMB_Write();
T0_Wait_ms(50);
//z轴偏移量
SMB_DATA_OUT_ADR=0x20;
SMB_DATA_OUT=0x05;
SMB_Write();
T0_Wait_ms(50);
//数据格式 中断输出电平定义
SMB_DATA_OUT_ADR=0x31;
SMB_DATA_OUT=0x5c;
SMB_Write();
T0_Wait_ms(50);
//中断使能 SINGLETAP 0122
SMB_DATA_OUT_ADR=0x2e;
SMB_DATA_OUT=0x40;
SMB_Write();
T0_Wait_ms(50);

Outcomes