完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
喜
我正在尝试通过I2C编程LIS2DH,使用STM32l151rb。我对活动模式感兴趣,为了使用连接到一个微型唤醒引脚的INT2引脚唤醒stm32l1。 我的配置是: / * CTRL_REG1 * / 0x29,// 0b0010 1001 ODR @ 10Hz,低功耗模式使能,Z禁用,Y禁用,X使能,应消耗3uA / * CTRL_REG2 * / 0x00, / * CTRL_REG3 * / 0x00,//禁用所有INT1中断 / * CTRL_REG4 * / 0x10,// 0b0001 0000 FS = +/- 4G,禁用自检 / * CTRL_REG5 * / 0x00,//不要锁存 / * CTRL_REG6 * / 0x08,// 0b0000 1000启用INT2上的活动中断 / * REFERENCE * / 0x00,//为0x1e / * INT2_CFG * / 0x02,// 0b0000 0010在X高事件上启用INT2中断生成 / * INT2_THS * / 0x20, / * INT2_DUR * / 0x10, / * ACT_THS * / 0x21,// 0x1e = 1000mG(9.81 m / s ^ 2)@ 4G FS参见数据表的表84(第48页) / * ACT_DUR * / 0x14}; // 0x01 = ~1秒(900毫秒)参考datetsINT2_THS的表86(第48页),INT2_DUR被设置为ACT regs仅用于调试。 我正在读取(用于调试)OUT_X / Y / Z_H寄存器并且它们的行为有意义,就像INT2_SRC一样,每当X轴超过阈值时我得到0x16。但是,作为INT2引脚的IA总是很低。 我错过了什么配置? #lis2dh #activity#int2 以上来自于谷歌翻译 以下为原文 hi, I'm trying to program a LIS2DH via I2C, with a stm32l151rb. I'm interested in the activity mode, in order to wake up the stm32l1 using the INT2 pin connected to one micro's wake-up pin. my configuration is: /*CTRL_REG1*/ 0x29, //0b0010 1001 ODR@10Hz, LowPower mode enabled, Z disabled, Y disabled, X enabled, should drain 3uA /*CTRL_REG2*/ 0x00, /*CTRL_REG3*/ 0x00, //disable all INT1 interrupts /*CTRL_REG4*/ 0x10, //0b0001 0000 FS = +/- 4G, self test disabled /*CTRL_REG5*/ 0x00, //do not latch /*CTRL_REG6*/ 0x08, //0b0000 1000 enable activity interrupt on INT2 /*REFERENCE*/ 0x00, //was 0x1e /*INT2_CFG*/ 0x02, //0b0000 0010 enable INT2 interrupt generation on X high events /*INT2_THS*/ 0x20, /*INT2_DUR*/ 0x10, /*ACT_THS*/ 0x21, //0x1e = 1000mG (9.81 m/s^2)@4G FS refer to table 84 (pg.48) of datasheet /*ACT_DUR*/ 0x14}; //0x01 = ~1 sec (900msec) refer to table 86 (pg.48) of datasheetINT2_THS and INT2_DUR are set as ACT regs just for debug. I'm reading (for debug) the OUT_X/Y/Z_H regs and they behave meaningfully, just as INT2_SRC as I get a 0x16 whenever the X-axis exceeds the threshold. However, the IA, as the INT2 pin, is always low. what configuration am I missing? #lis2dh #activity #int2 |
|
相关推荐
5个回答
|
|
我想,你混合了两个功能:
- 中断发生器2,由INT2_CFG,INT2_THS,INT2_DUR寄存器 - 活动/不活动检测配置,由ACT_THS,ACT_DUR寄存器配置 活动/不活动检测能够检测设备是否静止并自动将ODR降低到10 Hz,从而降低功耗。但是因为您使用ODR 10Hz作为默认配置,在这种情况下,活动/不活动功能对您来说是无用的。 acitivity / inactive活动的状态通过设置CTRL_REG6 = 0x08链接到INT2,并且它是有效的(我已经验证了它)。 您配置中断发生器2将阈值设置为1000mg,持续时间为1.6s,以便触发中断,您需要在X轴上产生高于1g的加速度超过1.6s。 1g可能是个问题,也许你应该把它减少到0.8g。您应该看到INT1_SRC中的IA位已设置。要将中断发生器2的状态链接到INT2引脚,应将CTRL_REG6设置为0x20。 以上来自于谷歌翻译 以下为原文 I think, you are mixing two features: - interrupt generator 2 which is configured by INT2_CFG, INT2_THS, INT2_DUR registers- activity/inactivity detection, configured by ACT_THS, ACT_DUR registers Activity/Inactivity detection is able to detect if the device is still and automatically reduce the ODR to 10 Hz and so reduce power consumption. But because you are using ODR 10Hz as default configuration the activity/inactivity feature is useless for you in this case. The status of acitivity/inactivity feature is linked to INT2 by settings CTRL_REG6 = 0x08, and it is functional (I have validated it). You configuration of interrupt generator 2 set the threshold to 1000mg and duration 1.6s so to trigger the interrupt you need to generate acceleration higher than 1g in X axis for more than 1.6s. 1g can be a problem, maybe you should reduce it to 0.8g for example. Than you should see that the IA bit in INT1_SRC is set. To link the status of interrupt generator 2 to INT2 pin you should set the CTRL_REG6 to 0x20. |
|
|
|
感谢Miroslav的快速回复,
正如我所说,许多配置都是为了调试而保留的,但我从你的回复中感觉到这些相互冲突,实际上不是吗? 对于中断生成的问题,您确定在1.6秒后触发中断吗?按照 http://www.st.com/content/ccc/resource/technical/document/application_note/group0/55/ef/e4/9f/d1/e9/46/2c/DM00365457/files/DM00365457.pdf/jcr:内容/翻译/ en.DM00365457.pdf ,第53页,中断应该在超过阈值后立即触发,而不是在持续时间之后触发,而是在返回睡眠时发生。我将按照您指出的方向进行一些测试并返回给您。在此期间非常感谢你。 以上来自于谷歌翻译 以下为原文 thanks Miroslav for your quick response, as I said, many of the configurations are kept for debug, but I sense from your reply that these conflict with each other, don't they actually? For what concerns che interrupt generations, are you sure that the interrupt is triggered after 1.6 secs? as per http://www.st.com/content/ccc/resource/technical/document/application_note/group0/55/ef/e4/9f/d1/e9/46/2c/DM00365457/files/DM00365457.pdf/jcr:content/translations/en.DM00365457.pdf , page 53, the interrupt should be triggered instantly after passing the threshold and not after the duration, which instead happens on return-to-sleep.I shall make some tests in the direction you pointed out and get back to you. Thank you very much in the meantime. |
|
|
|
你好Miroslav,
我做了一些测试,但没有运气。 我试图将极性反转几次,看看加速度计是否能够像实际那样正确地驱动线路。 我禁用了活动模式,然后输入配置: / * CTRL_REG1 * / 0x29,// 0b0010 1001 ODR @ 10Hz,低功耗模式使能,Z禁用,Y禁用,X使能,应消耗3uA / * CTRL_REG2 * / 0x00 / * CTRL_REG3 * / 0x00,//禁用所有INT1中断 / * CTRL_REG4 * / 0x10,// 0b0001 0000 FS = +/- 4G,禁用自检 / * CTRL_REG5 * / 0x02,//在int2上执行锁存 / * CTRL_REG6 * / 0x62,// 0b0--0 0010启用INT2中断,禁用INT2上的活动中断,极性反转 / * REFERENCE * / 0x00,//为0x1e / * INT2_CFG * / 0x02,// 0b0000 0010在X高事件上启用INT2中断生成 / * INT2_THS * / 0x20, / * INT2_DUR * / 0x02,//降低持续时间 / * CLICK_CFG * / 0x00, / * CLICK_SRC * / 0x00, / * CLICK_THS * / 0x00, / * TIME_LIMIT * / 0x00, / * TIME_LATENCY * / 0x00, / * TIME_WINDOW * / 0x00, / * ACT_THS * / 0x00,//禁用,0x1e = 1000mG(9.81 m / s ^ 2)@ 4G FS参见数据表的表84(第48页) / * ACT_DUR * / 0x00}; //禁用,0x01 = ~1秒(900毫秒)参考数据表的表86(第48页)我不认为我在reg6中得到了中断函数1和2的含义,我没有找到关于该主题的文档,可以你帮忙吗?我测试了三种配置中的任何一种(01,10,11),但结果是一样的。 我还在INT2上设置了锁存器,以查看INT2引脚是否与lis2dh的内部状态有任何不同。我用这段代码循环检查INT2_SRC: 而(1) { uint8_t ret,res_int; ret = mems_ReadMem_B(ACCELReg_INT2_SRC,& res_int); if((res_int& 0x42)!= 0) { ret = mems_ReadMem_B(ACCELReg_INT2_SRC,& res_int); } (无效)ret; 代码仔细检查INT2_SRC中的IA和XH以及IA位,第二次读取应确保IA位清零。那个寄存器在某种程度上表现得很奇怪: 它通常设置为0x15,其中acelerometer静止(不应该是0x01,而是?我明确地重置Z,Y和X LIE位);当我激发acelerometer时,寄存器变为0x16,这很好,但是永远不会设置IA位 以上来自于谷歌翻译 以下为原文 Hi Miroslav, I made some tests but had no luck. I tried to invert the polarity a few times to see if the accelerometer is able to drive the line correctly as it actually does. I disabled the activity mode and then put the configuration: /*CTRL_REG1*/ 0x29, //0b0010 1001 ODR@10Hz, LowPower mode enabled, Z disabled, Y disabled, X enabled, should drain 3uA /*CTRL_REG2*/ 0x00 /*CTRL_REG3*/ 0x00, //disable all INT1 interrupts /*CTRL_REG4*/ 0x10, //0b0001 0000 FS = +/- 4G, self test disabled /*CTRL_REG5*/ 0x02, //do latch on int2 /*CTRL_REG6*/ 0x62, //0b0--0 0010 enable interrupts on INT2, disable activity interrupt on INT2, polarity inversed /*REFERENCE*/ 0x00, //was 0x1e /*INT2_CFG*/ 0x02, //0b0000 0010 enable INT2 interrupt generation on X high events /*INT2_THS*/ 0x20, /*INT2_DUR*/ 0x02, //lowered duration /*CLICK_CFG*/ 0x00, /*CLICK_SRC*/ 0x00, /*CLICK_THS*/ 0x00, /*TIME_LIMIT*/ 0x00, /*TIME_LATENCY*/ 0x00, /*TIME_WINDOW*/ 0x00, /*ACT_THS*/ 0x00, //disabled, 0x1e = 1000mG (9.81 m/s^2)@4G FS refer to table 84 (pg.48) of datasheet /*ACT_DUR*/ 0x00}; //disabled, 0x01 = ~1 sec (900msec) refer to table 86 (pg.48) of datasheetI don't think I get the meaning of interrupt function1 and 2 in reg6, I've found no documentation on the topic, could you help on that? I have test any of the three configurations (01,10,11) but the result is the same. I have also set the latch on INT2 to see whether the INT2 pin differs in any way from the internal state of the lis2dh. I cyclically check the INT2_SRC, with this code: while (1) { uint8_t ret, res_int; ret=mems_ReadMem_B(ACCELReg_INT2_SRC, &res_int); if ((res_int&0x42) != 0) { ret=mems_ReadMem_B(ACCELReg_INT2_SRC, &res_int); } (void) ret; }The code double-checks the IA and the XH and the IA bits in the INT2_SRC, the second read should assure that the IA bit is cleared. That register behaves somehow wierdly:
|
|
|
|
在CTRL_REG6中,您可以设置链接到INT2引脚的功能。当您使用中断发生器2产生中断时,您应该只设置I2_INT2位,因此寄存器的值将为0x22。如果INT1_SRC等于0x15,则表示所有三个轴中的值都低于阈值,所有三个轴均被评估如果只启用一个轴如果在INT1_SRC中看到0x16,则表示X轴的加速度高于阈值,但是尚未达到持续时间,因此尚未生成中断请降低阈值(
INT2_THS) 正如我在上一篇文章中推荐的那样,否则要触发中断,你必须在X轴上生成加速度> 1g至少200ms。 以上来自于谷歌翻译 以下为原文
INT2_THS) as I recommend you in my previous post, otherwise to trigger the interrupt you have to generate acceleration in X axis >1g for at least 200ms. |
|
|
|
原来,Gravity LIS2DH套件上有错误的标签。他们只是颠倒了INT1& INT2!
通过看到INT2_SRC正在正确移动而引脚没有移动,我得到了它。 谢谢 - 对于这个主题的大帮助,toby正确使用INT2。 以上来自于谷歌翻译 以下为原文 turned out that Gravity LIS2DH kit has wrong labels on it. they just inverted INT1 & INT2!! I got to it by seeing that INT2_SRC was moving correctly while the pin didn't. thanks ​ for the big help on the topic, toby exlaining the correct use of INT2. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2715 浏览 1 评论
3235 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1807 浏览 1 评论
3643 浏览 6 评论
6031 浏览 21 评论
1333浏览 4评论
207浏览 3评论
195浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
348浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
440浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 14:34 , Processed in 1.502308 second(s), Total 55, Slave 48 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号