Question: MSP430 C code Change the code so that when the button is pressed the LED should start blinking and continue to blink when the button

MSP430 C code

Change the code so that when the button is pressed the LED should start blinking and continue to blink when the button is released. When the button is pressed again the LED should turn on and remain on when the button is released.

#include

/* * Swtich S1 - P1.1 * LED1 - P1.0 */

void delay(void) { volatile unsigned loops = 50000; // Start the delay counter at 50,000 while (--loops > 0); // Count down until the delay counter reaches 0 }

void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

P1REN |= BIT1; // Connect resistor on P1.1 to P1OUT P1OUT |= BIT1; // Set output register for P1.1 to '1' P1DIR |= BIT0; // Make P1.0 an output PM5CTL0 &= ~LOCKLPM5; // Unlock ports from power manager for (;;) { delay(); // Run the delay sub-routine if (!(P1IN & BIT1)) // Read the input from P1.1 and check its state P1OUT |= BIT0; // If the button was pressed, turn on the LED else P1OUT &= ~BIT0; // If the button wasn't pressed, turn off the LED. } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!