Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Check if I am in LPM4

$
0
0

I am currently working on a battery operated wireless doorsensor.

A message is sent whenever a magnetic switch causes an interrupt.

 

I have read some topics on this forum and changed some lines in Winterrupts file and created the following sketch:

#include <x10rf.h>
#define intpin1       P1_5
#define txpin       P1_7
#define txvcc       P1_0
#define reps     4 	

x10rf myx10 = x10rf(txpin,0,reps);

void setup()
{
  myx10.begin();
  pinMode(intpin1,INPUT_PULLUP);
  pinMode(txvcc,OUTPUT);
  digitalWrite(intpin1, HIGH);
  digitalWrite(txvcc, LOW);
  attachInterrupt(intpin1, Wake, CHANGE);
}
 
void loop()
{ 
  LPM4;
}
void Wake()
{
  int state = digitalRead(intpin1);
  digitalWrite(txvcc, HIGH);
  switch(state) {
    case 0: 
      myx10.x10Security(3,0x84);
      break;
    case 1: 
      myx10.x10Security(3,0x04);
      break;
  }
  delay(10); 
  digitalWrite(txvcc, LOW);
}

This is working great but I have some questions.

 

How can I check that MCU is running in LPM4? Do I need CCS to check (debug) this or are there other ways?

At some point I want to add sensors to periodically report temperature and light conditions. What is a power efficient way to do this? I know timers don't work in LPM4. Should I switch to LPM3 or use an external circuit to wake the MCU every x minutes?

 

 

 


Viewing all articles
Browse latest Browse all 2077

Trending Articles