ST意法半导体
直播中

李欣

7年用户 168经验值
私信 关注
[问答]

LSM303D中断无法使用

我无法使点击中断适用于LSM303D。使用Pololu为arduino提供的库我可以将此代码用于DLHC



[码]
#include< Wire.h>
#include< LSM303.h>
long thisLong = 0;
LSM303指南针;
const byte interruptPin = 2;


void setup()
{
Serial.begin(9600);
Wire.begin();
compass.init();
compass.enableDefault();
compass.writeAccReg(LSM303 :: CTRL3,0b11000000);
compass.writeAccReg(LSM303 :: CTRL0,0b00000000);
compass.writeAccReg(LSM303 :: CLICK_CFG,0b00010000);
compass.writeAccReg(LSM303 :: CLICK_THS,0b00011111);
compass.writeAccReg(LSM303 :: tiME_LIMIT,0b00011111);


延迟(100);
attachInterrupt(digitalPinToInterrupt(interruptPin),reset,CHANGE);
}


void loop()
{
Serial.print(thisLong);
Serial.println( '' '');
thisLong ++;
延迟(100);
}


void reset(){
thisLong = 0;
}
[/码]


但是当我在LSM303D上尝试时,它似乎不会产生中断。我可以读取CLICK_SRC寄存器并且中断显示有效,但INT1引脚永远不会从低电平变为高电平。有人一起工作吗?

以上来自于谷歌翻译


以下为原文





I am having trouble getting the click interrupts to work for the LSM303D. using the library provided by Pololu for arduino I can get this code working for the DLHC




  1. #include
  2. #include
  3. long thisLong = 0;
  4. LSM303 compass;
  5. const byte interruptPin = 2;


  6. void setup()
  7. {
  8.   Serial.begin(9600);
  9.   Wire.begin();
  10.   compass.init();
  11.   compass.enableDefault();   
  12.   compass.writeAccReg(LSM303::CTRL3,     0b11000000);
  13.   compass.writeAccReg(LSM303::CTRL0,     0b00000000);
  14.   compass.writeAccReg(LSM303::CLICK_CFG, 0b00010000);
  15.   compass.writeAccReg(LSM303::CLICK_THS, 0b00011111);
  16.   compass.writeAccReg(LSM303::TIME_LIMIT, 0b00011111);


  17.   delay(100);
  18.   attachInterrupt(digitalPinToInterrupt(interruptPin), reset, CHANGE);
  19. }


  20. void loop()
  21. {
  22.   Serial.print(thisLong);
  23.   Serial.println('''');
  24.   thisLong++;
  25.   delay(100);
  26. }


  27. void reset() {
  28.   thisLong = 0;
  29. }



But when I try it on the LSM303D it doesn't seem to generate the interrupt. I can read the CLICK_SRC register and the interrupt shows active, but the INT1 pin never goes from low to high. Anyone work with these at all?

回帖(1)

李欣

2018-9-12 16:45:50
说真的没有人有这样的问题吗?

以上来自于谷歌翻译


以下为原文




Seriously no one has had issues like this?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分