Question

In: Electrical Engineering

using code composer studio 1. write a program for the msp430fr6989 that will light LED1, whenever...

using code composer studio 1. write a program for the msp430fr6989 that will light LED1, whenever S1 is pressed. It should turn off whenever S1 is released.

2. Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop.

Solutions

Expert Solution

1)

#include <msp430fr6989.h>
#define LED_0 BIT0 
#define LED_OUT P1OUT
#define LED_DIR P1DIR
#define BUTTON BIT3
unsigned int blink = 0;

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
LED_DIR |= (LED_0); // Set P1.0  to output direction
LED_OUT &= ~(LED_0); // Set the LEDs off
P1REN |= BUTTON; // puller-Resistor on the button-pin is enabled
P1OUT |= BUTTON; //Writes a "1" to the portpin
P1IES |= BUTTON; //Triggers when you PRESS the button 
P1IE |= BUTTON;
__enable_interrupt(); // Interrupts get enabled
for (;;)
{

if(blink > 0)
{
P1OUT ^= (LED_0); // on P1.0 
}
}

} 

// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
blink ^= 0x01;
P1IFG &= ~BUTTON; // P1.3 IFG cleared
LED_OUT &= ~(LED_0); // Clear the LED

}

2) Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop.

#include <msp430fr6989.h>
#define LED_0 BIT0 
#define LED_OUT P1OUT
#define LED_DIR P1DIR
#define BUTTON BIT3
unsigned int blink = 0;

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
LED_DIR |= (LED_0); // Set P1.0  to output direction
LED_OUT &= ~(LED_0); // Set the LEDs off
P1REN |= BUTTON; // puller-Resistor on the button-pin is enabled
P1OUT |= BUTTON; //Writes a "1" to the portpin
P1IES |= BUTTON; //Triggers when you PRESS the button 
P1IE |= BUTTON;
__enable_interrupt(); // Interrupts get enabled
for (;;)
{

if(blink > 0)
{
P1OUT ^= (LED_0); // on P1.0 
__delay_cycles(10000)
LED_OUT &= ~(LED_0)
P1OUT ^= (LED_0); // on P1.0 
__delay_cycles(10000)
LED_OUT &= ~(LED_0)
P1OUT ^= (LED_0); // on P1.0 
__delay_cycles(10000)
LED_OUT &= ~(LED_0)
P1OUT ^= (LED_0); // on P1.0 
__delay_cycles(10000)
LED_OUT &= ~(LED_0)
P1OUT ^= (LED_0); // on P1.0 
__delay_cycles(10000)
LED_OUT &= ~(LED_0)
}
}

} 

// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
blink ^= 0x01;
P1IFG &= ~BUTTON; // P1.3 IFG cleared
LED_OUT &= ~(LED_0); // Clear the LED

}

Related Solutions

1. write a program for the msp430fr6989 that will light LED1, whenever S1 is pressed. It...
1. write a program for the msp430fr6989 that will light LED1, whenever S1 is pressed. It should turn off whenever S1 is released. 2. Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop.
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
For the mspfr6989 write program #2 1(b) Write a program that will make LED1 blink 5...
For the mspfr6989 write program #2 1(b) Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop. Program #2 – Using both S1 and S2 1 Write a program like 1(b) above, but the LED1 will blink until S2 is pressed. 2 Write a program that simulates a motor coming up to speed. When S1 is pressed, LED1 blinks at 50% duty cycle for 10 cycles (indicating a motor coming up to speed)....
using Visual Studio write a code containing a main() program that implements the coin change state...
using Visual Studio write a code containing a main() program that implements the coin change state machine in C++ according to the guidance given in Translating a state machine to C++ Test your code using prices 1 and 91 cents, and assume change is calculated from a dollar bill. Copy and paste your console output to a text editor and save the result in a single file named console.txt. Upload your exercise081.cpp and console.txt files to Canvas.
write a program for the msp430fr6989 Using the general purpose timer, specifically the ACLK, create a...
write a program for the msp430fr6989 Using the general purpose timer, specifically the ACLK, create a program which makes LED1 stay on for 4 seconds and off for 2 seconds and repeat indefinitely. Modify the above program to extend the timing to 20 and 10 seconds, respectively.
write a c++ program using micro soft visual studio 2010 to write a program and store...
write a c++ program using micro soft visual studio 2010 to write a program and store 36 in variable x and 8 in variable y. add them and store the result in the variable sum. then display the sum on screen with descriptive text. calculate the square root of integer 36 in x. store the result in a variable. calculate the cube root of integer 8 in y. store result in a variable. display the results of square root and...
1.write a program for the msp430FR6989 to make led 1 blink at 50 percent duty cycle....
1.write a program for the msp430FR6989 to make led 1 blink at 50 percent duty cycle. 2 modify the program to make led 1 blink 5 times, make a long pause, then blink 5 more times then stop. The time delays should be carried out in subroutines
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that prompts the user to select a type of coffee she likes and 2) returns the object of what she selected to the console. #include "stdafx.h" #include <iostream> using namespace std; // Product from which the concrete products will inherit from class Coffee { protected:    char _type[15]; public:    Coffee()    {    }    char *getType()    {        return _type;   ...
Solve following using Program R studio. Please show code and results. Thank you. 1. Assume that...
Solve following using Program R studio. Please show code and results. Thank you. 1. Assume that ? is a random variable follows binomial probability distribution with parameters 15 and 0.25.   a. Simulate 100 binomial pseudorandom numbers from the given distribution (using set.seed(200)) and assign them to vector called binran. b. Calculate ?(? < 8) using cumulative probability function. c. Calculate ?(? = 8) using probability distribution function. d. Calculate the average of simulated data and compare it with the corresponding...
1.. Write a code that LED1 (Red LED- P1.0) turns ON when after you push S1(push...
1.. Write a code that LED1 (Red LED- P1.0) turns ON when after you push S1(push button - P1.1) five times and stays OFF forever after that. 2.. Write a code that LED1 (Red LED- P1.0) turns OFF and LED2 (Red LED- P9.7) Turns ON after you push S1(push button -P1.1) five times and they stay that way forever.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT