Jump to content
43oh

Kris

Members
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by Kris

  1. 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();

    }

     

×
×
  • Create New...