lpcware

wakeup from tilt sensor filter

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by tbelo on Mon Jul 14 04:24:39 MST 2014
Hi,

In my scenario I have 2 sources to wakeup from deep-sleep: a timer and a tilt sensor.
Everything works fine unless the noise from the tilt sensor that causes the system to wakeup too easy.
Can I add a timer and a counter to the WAKEUP_IRQHandler only for the tilt sensor pin to reduce noise ?

Following is my WAKEUP_IRQHandler code (wakeFromAlarmFlag is a volatile used for alarm purposes) :


void WAKEUP_IRQHandler(void){
/*CLEAR sleepdeep bit */
SCB->SCR&=~(1<<2);

/* Clear the match output register value */
LPC_TMR16B0->EMR  &= ~(1<<0);

/* Disable and Reset Timer */
LPC_TMR16B0->TCR = (1<<1);

uint32_t regVal;
regVal = LPC_SYSCON->STARTSRP0;
  if ((regVal & (1 << 8)) != 0){
  LPC_SYSCON->STARTRSRP0CLR|=(1<<(8)); //1 = Writing 1 resets the start signal. MISO TIMER16
  LPC_SYSCON->STARTRSRP0CLR|=(1<<(12)); //rst the tilt start signal in case it is buffered from previous alrms

  if (wakeFromAlarmFlag>0 && wakeFromAlarmFlag<ALARMNOTIFIRIER)
  wakeFromAlarmFlag++;
  else wakeFromAlarmFlag=0;

  }
  else {
  LPC_SYSCON->STARTRSRP0CLR|=(1<<(12)); //AD1 TILT
  wakeFromAlarmFlag++;
  }

  NVIC_DisableIRQ(WAKEUP8_IRQn);
  NVIC_DisableIRQ(WAKEUP12_IRQn);
  NVIC_ClearPendingIRQ(WAKEUP12_IRQn);
  NVIC_ClearPendingIRQ(WAKEUP8_IRQn);

return;
}

Outcomes