C CODE LANGUAGE. MSP430.
#include <msp430fr6989.h>
#define redLED BIT0 // Red LED at P1.0
#define greenLED BIT7 // Green LED at P9.7
#define BUT1 BIT1 // Button S1 at P1.1
#define BUT2 BIT2 // Button S2 at P1.2
void main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop the Watchdog timer
PM5CTL0 &= ~LOCKLPM5; // Enable the GPIO pins
// Configure and initialize LEDs
P1DIR |= redLED; // Direct pin as output
P9DIR |= greenLED; // Direct pin as output
P1OUT &= ~redLED; // Turn LED Off
P9OUT &= ~greenLED; // Turn LED Off
// Configure buttons1
P1DIR &= ~(BUT1 | BUT2); // Direct pin as input
P1REN |= (BUT1 | BUT2); // Enable built-in resistor
P1OUT |= (BUT1 | BUT2); // Set resistor as pull-up
// Polling the button in an infinite loop
for(;;) {
// Fill the if-statement below...
if((P1IN & BUT1)==0)
P1OUT |= redLED; // Turn red LED on
else P1OUT &= ~redLED; // Turn red LED off
if((P1IN & BUT2)==0)
P9OUT |= greenLED; // Turn green LED on
else P9OUT &= ~greenLED; //Turn green LED off
}
}
C CODE LANGUAGE. MSP430.
#include <msp430fr6989.h>
#define redLED BIT0 // Red LED at P1.0
#define greenLED BIT7 // Green LED at P9.7
#define BUT1 BIT1 // Button S1 at P1.1
#define BUT2 BIT2 // Button S2 at P1.2
void main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop the Watchdog timer
PM5CTL0 &= ~LOCKLPM5; // Enable the GPIO pins
// Configure and initialize LEDs
P1DIR |= redLED; // Direct pin as output
P9DIR |= greenLED; // Direct pin as output
P1OUT &= ~redLED; // Turn LED Off
P9OUT &= ~greenLED; // Turn LED Off
// Configure buttons1
P1DIR &= ~(BUT1 | BUT2); // Direct pin as input
P1REN |= (BUT1 | BUT2); // Enable built-in resistor
P1OUT |= (BUT1 | BUT2); // Set resistor as pull-up
// Polling the button in an infinite loop
for(;;) {
// Fill the if-statement below...
if((P1IN & BUT1)==1 && BUT2==0)
P1OUT |= redLED; // Turn red LED on
else if (BUT2==1)
P9OUT |= greenLED; // Turn green LED on
BUT1=0
else P1OUT &= ~redLED; // Turn red LED off
if((P1IN & BUT2)==1 && BUT1==0)
P9OUT |= greenLED; // Turn green LED on
else if (BUT1==1)
P1OUT |= redLED; // Turn red LED on
BUT2=0
else P9OUT &= ~greenLED; //Turn green LED off
}
}
C CODE LANGUAGE. MSP430. #include <msp430fr6989.h> #define redLED BIT0 // Red LED at P1.0 #define greenLED...
Help modify below code using the timer Timer_A to toggle two LEDs in periodic time intervals of A)10 sec B)30 sec C)1 sec the original code toggled red LED when an overflow occured: #include <ms430.h> #define RedLED BIT0 #define RedLEDToggle (P1OUT ^= RedLED) void main (void) { WDTCTL = WDTPW|WDTHOLD; P1DIR = RedLED; P1OUT = RedLED; TECTL = TASSEL_2|ID_3|MC_3|TAIE; TACCR0 = 62500; _enable_interrupts(); LPM1; //enter low power mode } #pragma vector=TIMER_A1_VECTOR __interrupt void Timer_A(void) { switch(TAIV) { case 0x02:...
I need help with doing these tasks for code composer Lab 3 - Branching, Push Button and LEDs-Reading Assignment in this lab, we are going to control a LED via a push button- using general purpose digital 10 for both input (button) and output (LED) on port 1 - using Code Composer Studio. Furthermore, we are going to use a branch instruction to create an IF-ELSE structure in assembly to determine if the LED should be lit up based on...