我打算使用LIS3DH作为一个功率非常低的活动探测器,但是在我的应用程序中使用它的中断输出没有成功:我可以让它始终保持开启或始终关闭但从不对运动作出反应。
为了保持理智,我已经回到了应用笔记和编写的代码,它完全符合应用笔记(第6.3.3节)所说的但是我无法做到这一点:我可以看到X / Y / Z值改变但INT1_SRC中的IA位从未设置,无论我如何猛烈地摇动芯片(通过I2C连接的STEVAL-MKI105V1板)。我究竟做错了什么?帮帮我!
我的代码(在mbed-os中,在
STM32F437VG上运行)附加到这篇文章,它的输出如下:
读I_AM_LIS3DH(0x0f):0x33。
写CTRL_REG1(0x20):0x57。
写CTRL_REG2(0x21):0x09。
写CTRL_REG3(0x22):0x40。
写CTRL_REG4(0x23):0x00。
写CTRL_REG5(0x24):0x08。
写INT1_THS(0x32):0x10。
写INT1_DURA
tiON(0x33):0x00。
读参考(0x26):0x00。
写INT1_CFG(0x34):0x2a。
读INT1_SRC(0x31):0x00。
阅读X 64 Y 64 Z 65472。
读INT1_SRC(0x31):0x00。
阅读X 65472 Y 65472 Z 0。
读INT1_SRC(0x31):0x00。
读X 64 Y 0 Z 65472。
读INT1_SRC(0x31):0x00。
读X 0 Y 65472 Z 0。
读INT1_SRC(0x31):0x00。
读X 0 Y 0 Z 65472。
读INT1_SRC(0x31):0x00。
读X 0 Y 64 Z 65472。
读INT1_SRC(0x31):0x00。
读X 0 Y 65408 Z 0。
读INT1_SRC(0x31):0x00。
读X 65472 Y 0 Z 0。
读INT1_SRC(0x31):0x00。
阅读X 65408 Y 0 Z 65472。
读INT1_SRC(0x31):0x00。
...
读X 0 Y 64960 Z 1088。
读INT1_SRC(0x31):0x00。
阅读X 1088 Y 2496 Z 65088。
读INT1_SRC(0x31):0x00。
阅读X 1216 Y 64832 Z 63808。
读INT1_SRC(0x31):0x00。
阅读X 1408 Y 1280 Z 63424。
读INT1_SRC(0x31):0x00。
阅读X 1792 Y 4608 Z 63168。
读INT1_SRC(0x31):0x00。
阅读X 65472 Y 0 Z 64320。
读INT1_SRC(0x31):0x00。
读X 256 Y 768 Z 1600。
读INT1_SRC(0x31):0x00。
阅读X 1792 Y 3520 Z 2688。
读INT1_SRC(0x31):0x00。
阅读X 128 Y 1216 Z 64576。
读INT1_SRC(0x31):0x00。
...
抢
#lis3dh
以上来自于谷歌翻译
以下为原文
I intend to use the LIS3DH as a very low power activity detector but have had no success in getting its interrupt output to behave in my application: I can make it stay always on or always off but never does it react to motion.
To retain my sanity, I have gone back to the application note and written code which does
exactly what the application note (section 6.3.3) says but I can't make that work either: I can see the X/Y/Z values changing but the IA bit in INT1_SRC is never set, no matter how violently I shake the chip (which is on an STEVAL-MKI105V1 board attached via I2C). What am I doing wrong? Help!
My code (in mbed-os, running on an STM32F437VG) is attached to this post, its output is below:
Read I_AM_LIS3DH (0x0f): 0x33.
Write CTRL_REG1 (0x20): 0x57.
Write CTRL_REG2 (0x21): 0x09.
Write CTRL_REG3 (0x22): 0x40.
Write CTRL_REG4 (0x23): 0x00.
Write CTRL_REG5 (0x24): 0x08.
Write INT1_THS (0x32): 0x10.
Write INT1_DURATION (0x33): 0x00.
Read REFERENCE (0x26): 0x00.
Write INT1_CFG (0x34): 0x2a.
Read INT1_SRC (0x31): 0x00.
Read X 64 Y 64 Z 65472.
Read INT1_SRC (0x31): 0x00.
Read X 65472 Y 65472 Z 0.
Read INT1_SRC (0x31): 0x00.
Read X 64 Y 0 Z 65472.
Read INT1_SRC (0x31): 0x00.
Read X 0 Y 65472 Z 0.
Read INT1_SRC (0x31): 0x00.
Read X 0 Y 0 Z 65472.
Read INT1_SRC (0x31): 0x00.
Read X 0 Y 64 Z 65472.
Read INT1_SRC (0x31): 0x00.
Read X 0 Y 65408 Z 0.
Read INT1_SRC (0x31): 0x00.
Read X 65472 Y 0 Z 0.
Read INT1_SRC (0x31): 0x00.
Read X 65408 Y 0 Z 65472.
Read INT1_SRC (0x31): 0x00.
...
Read X 0 Y 64960 Z 1088.
Read INT1_SRC (0x31): 0x00.
Read X 1088 Y 2496 Z 65088.
Read INT1_SRC (0x31): 0x00.
Read X 1216 Y 64832 Z 63808.
Read INT1_SRC (0x31): 0x00.
Read X 1408 Y 1280 Z 63424.
Read INT1_SRC (0x31): 0x00.
Read X 1792 Y 4608 Z 63168.
Read INT1_SRC (0x31): 0x00.
Read X 65472 Y 0 Z 64320.
Read INT1_SRC (0x31): 0x00.
Read X 256 Y 768 Z 1600.
Read INT1_SRC (0x31): 0x00.
Read X 1792 Y 3520 Z 2688.
Read INT1_SRC (0x31): 0x00.
Read X 128 Y 1216 Z 64576.
Read INT1_SRC (0x31): 0x00.
...
Rob
#lis3dh