已回答假定已回答

ADXL345  autosleep mode

stevenlin08 在 2016-5-4 詢問的問題
最後回覆由neilzhao於2016-5-10提供

hi all,

i need a function moving detector at sleep mode.

so , i find ADXL345 datasheet about auto sleep.

Now, it not work correctly that not action auto the auto sleep mode.

but it can do when i set POWER_CTL reg bit 3 (Measure bit,see my code)

 

have any Suggest about my code

 

i ref follow post,

如何解决自动休眠模式唤醒后,需要同时检测活动和静止功能。

https://ezchina.analog.com/message/17677#17677

ADXL345  Activity与Inactivity 问题咨询

https://ezchina.analog.com/message/33051#33051

 

 

My code:

  if(! setFullResolution(true))//0x31

      return false;

 

  setSampleRate(ADXL345_RATE_400);

 

  setIntActivityPin(0);

  setIntInActivityPin(1);

 

  setActivityXEnabled(1);

  setActivityYEnabled(1);

  setActivityZEnabled(1);

  setInactivityXEnabled(1);

  setInactivityYEnabled(1);

  setInactivityZEnabled(1);

  

  setActivityThreshold(0x30);

  setInactivityThreshold(0x20);

  setInctivityTime(0x01);

  setActivityAC(true);

 

  setInterruptMode(true); //set io as low action

 

 

  setIntMask(ADXL345_INT_ACTIVITY_MASK|ADXL345_INT_INACTIVITY_MASK);//int enable(inaction /action)

 

  setLinkEnabled(true);//to auto sleep

  setAutoSleepEnabled(true);

  //sensorWriteBits(ADXL345_RA_POWER_CTL,ADXL345_PCTL_MEASURE_BIT,1,1);

 

setFullResolution

setFullResolution.png

setSampleRate

setSampleRate.png

setIntActivityPin

setIntActivityPin0.png

setIntInActivityPin

setIntActivityPin1.png

setActivityXEnabled

setActivityXEnabled.png

setActivityThreshold

setActivityThreshold.png

setInactivityThreshold

setInactivityThreshold.png

setInctivityTime

setInctivityTime.png

setActivityAC

setActivityAC.png

setInterruptMode

setInterruptMode.png

setIntMask

setIntMask.png

setLinkEnabled

setLinkEnabled.png

setAutoSleepEnabled

setAutoSleepEnabled.png

結果