I can blink the led but the time of it's very 1 second or 2 second.I try to increase but it did not.But my question I'm using L293D motor driver to control motors.I want to Dc motors turn when button switched 15 second.This my code but I can't find a solution.I m asking how to increase the time
#include "io430.h" void delay(unsigned long int d) { d*=9999999999999999; for(;d>0;d--); } void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR = BIT6 + BIT4 + BIT7 + BIT0; // Toggle P1.0 using exclusive-OR P1DIR &= ~BIT3; if((P1IN&BIT3) == 0){ P1OUT |= BIT6 + BIT4 + BIT7; } else { P1OUT |= BIT0; delay(9000); } }
Best Answer
My suggestion would be get rid of the delay function and use the built in if you are using IAR or CCS."__delay_cycles (cycles);" using the built ins, will give you more predicable results and better timing. You could probably just replace your delay for the built in, to get closer to the results you are looking for.
personally I would go about the whole thing using interrupts and timers to pull the whole thing off and use the peripherals that the msp430 has. I would suggest using the WDT as an interval timer, doing this would leave the other timer for your motor control. p1.3 is used as the wake up pin and p1.0 is the led pin.
example code
Not complete nor has this code been tested, but it should turn the led on for 15 seconds every time the P1.3 button is pushed.