Jump to content
Sign in to follow this  
Kris

servo.detach() for LPM4

Recommended Posts

Hi All,

 

I was wondering if anyone could help? I am trying to drive a servomotor using MSP-EXP430F5529LP. I need to drive the servo to a position, then I disconnect power to the servo using an analog switch. The servo isn't under any great load, so it doesn't move when power is disconnected. Problem is MSP430 is still drawing ~ 525 uA. When I comment out myservo.attach(P2_5), the current consumption drops to the desired 2 uA. I've stripped away most of the code to aid debugging (see below). As far as I can tell, servo.attach() is what's causing the problem. I've read elsewhere that servo.detach() simply stops PWM signals from reaching the previously attached pin (P2_5) and that the timer is still running. Presumably this is why I'm drawing so much current. Can I just set the mode control bit in the TACTL register to stop the timer? Not sure if this would be enough?

 

#include <Servo.h> 
 
Servo myservo; 

void setup() 

  P1DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
  P1OUT &= (~BIT0)+(~BIT1)+(~BIT2)+(~BIT3)+(~BIT4)+(~BIT5)+(~BIT6)+(~BIT7);
  P2DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT6+BIT7;
  P2OUT &= (~BIT0)+(~BIT1)+(~BIT2)+(~BIT3)+(~BIT4)+(~BIT6)+(~BIT7);
  P3DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
  P3OUT &= (~BIT0)+(~BIT1)+(~BIT2)+(~BIT3)+(~BIT4)+(~BIT5)+(~BIT6)+(~BIT7);
  P4DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
  P4OUT &= (~BIT0)+(~BIT1)+(~BIT2)+(~BIT3)+(~BIT4)+(~BIT5)+(~BIT6)+(~BIT7);
  P5DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
  P5OUT &= (~BIT0)+(~BIT1)+(~BIT2)+(~BIT3)+(~BIT4)+(~BIT5)+(~BIT6)+(~BIT7);
  P6DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
  P6OUT &= (~BIT0)+(~BIT1)+(~BIT2)+(~BIT3)+(~BIT4)+(~BIT5)+(~BIT6)+(~BIT7);
  P7DIR |= BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6+BIT7;
  P7OUT &= (~BIT0)+(~BIT1)+(~BIT2)+(~BIT3)+(~BIT4)+(~BIT5)+(~BIT6)+(~BIT7);
  P8DIR |= BIT0+BIT1+BIT2;
  P8OUT &= (~BIT0)+(~BIT1)+(~BIT2);
  
  myservo.attach(P2_5); 
  delay(100);
  myservo.detach();

  



 
 
void loop() 

suspend();

}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...