Question

Lab 3 - Branching, Push Button and LEDs-Reading Assignment in this lab, we are going to control a LED via a push button- usin



Write three programs (starting with a copy of Lab 2) that configures the registers above to make P1.6 as an output for the LE

e workspace v8-Lab 2/blink.c-Code Composer Studio ile Edit View Project Run Tools Scripts Window Help ▼MG/ |少閨画3.co.t. 圈 9,la

I need help with doing these tasks for code composer

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer :- 3)a) The code can be written as-

#include <msp430.h>

vaoid main(void)
{

WDTCTL = WDTPW | WDTHOLD;
P1DIR |= 0x40;
P1REN = 0x01;
P1IN = ~0x08;
P1OUT = 0x40;

while(1)
{
if(P1IN & 0x08) /* if button is pressed */
P1OUT |= 0x04; /* make led on if button is pressed */
else
P1OUT &= ~0x04; /* else make led off */
}

}

Answer :- 3)c) Assuming green LED is at pin 1.5 as it is difficult to find out the poin for green LED from the attached figure.The code can be written as-

#include <msp430.h>

vaoid main(void)
{

WDTCTL = WDTPW | WDTHOLD;
P1DIR |= 0x60; /* making pin6 and pin5 both as output pin by writing 0110_0000 */
P1REN = 0x01;
P1IN = ~0x08;
P1OUT = 0x40; /* initially making red led on and green led off */

while(1)
{
if(P1IN & 0x08) /* if button is pressed */
P1OUT ^= 0x02; /* make green led to blink by toggling each time */
else
P1OUT ^= 0x04; /* else make red led to blink */
}

}

Dear student, to write the code for part b we need processors working frequency so that we can calculate the delay count value. You can write the value in the comment section. Thank you.

Add a comment
Know the answer?
Add Answer to:
I need help with doing these tasks for code composer Lab 3 - Branching, Push Button...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C CODE LANGUAGE. MSP430. #include <msp430fr6989.h> #define redLED BIT0 // Red LED at P1.0 #define greenLED...

    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...

  • Question 3: In class we showed how to simply light up an LED on our Teensy...

    Question 3: In class we showed how to simply light up an LED on our Teensy microcontroller. In fact, the procedure is similar for all processors including a simpler 8-bit ATmega 328P (a.k.a Arduino Uno) For purposes of this exercise, let's say that the ATmega328 has 4 regular GPIO ports; A, B, C, and D, each with 8 pins. Every GPIO port has three registers (outlined in table below) PORTX: used to write output on a pin on port X...

  • 2. Given the following setup for GPIO (fill in all the blanks, refer to pages 1-4)...

    2. Given the following setup for GPIO (fill in all the blanks, refer to pages 1-4) GPIOB_MODER 0x10000 //GPIOB_OTYPER is not needed as its default value is zero GPIOB_OSPEEDRI=0x3000; GPIOBPUPDRI= 0x80; - a. Which port is being initialized? Port b. Describe the important features from the initialization for pin 3 Ifor example input, output, alternate function, analog, pull up, pull down, push/pull, open drain out, speed, etc.). Px3 is initialized to be c. Which pin is being initialized as an...

  • Lab 1-Lab Portion Part I Copy the Blink program from Figure 1-13 (page 17) in the textbook and run it on your Arduino. After verifying that the Blink program works, modify the program to make the...

    Lab 1-Lab Portion Part I Copy the Blink program from Figure 1-13 (page 17) in the textbook and run it on your Arduino. After verifying that the Blink program works, modify the program to make the on-board LED attached to pin #13 blink out "SOS" in Morse code. Use a 2 750 millisecond for long pulses. 50 millisecond for short pulses and a Part 2, Write a program that uses two pushbuttons to increase or decrease the brightness of the...

  • can you please solve in c and clear 1 - General purpose eneral purpose 1/0 [30...

    can you please solve in c and clear 1 - General purpose eneral purpose 1/0 [30 pts re going to use the DDR, PORT, and PIN registers from your AVR device ions are the same as your AVR device). Assume that your AVR has. LED2) connected to pins 0, 1, 2 of Port C, respectively. In this question, you are going (the register definitions are the san • I pushbutton connected to pin 3 and Port C • 3 LEDs...

  • I am doing an Arduino Uno project where I made a "Simon says" memory game with 3 neopixel LED str...

    I am doing an Arduino Uno project where I made a "Simon says" memory game with 3 neopixel LED strips and 3 - ultrasonics. I have them working independently but I need to combine the code so they work together. Here is what I have: Memory Game #define PLAYER_WAIT_TIME 2000 // The time allowed between button presses - 2s byte sequence[100]; // Storage for the light sequence byte curLen = 0; // Current length of the sequence byte inputCount =...

  • Code the following example and screenshot the text output. After you have the test code working,...

    Code the following example and screenshot the text output. After you have the test code working, modify it so that it has the following features: ○ The ‘while’ loop is inside a try/except error check. This allows a <CTRL>C to break out of the loop ○ Keep track of the number of button presses with an accumulator variable ○ After the loop is ended with an exception, create an attractive output which tells the user that the program has ended...

  • I need help with the following code... Instructions: This lab builds on the skills from Lab...

    I need help with the following code... Instructions: This lab builds on the skills from Lab 2c, in which you read data values from a file and kept a count of the number of invalid values. In this lab, your program will be using the same code to read each data entry from the file, but you will also save each value in an array named allMags after each is read in. When all values in the file have been...

  • Could you please show me how I can drw those circuits. please using (NI Multisim 14)...

    Could you please show me how I can drw those circuits. please using (NI Multisim 14) Optocoupler Objectives Use an ohmmeter to determine the condition of the optoisolator. Observe the operation of an optocoupler. Determine the maximum frequency response of the optocoupler. Required Materials (1) Dual DC power supply (1) Function generator (1) Oscilloscope (2) Multimeters (1) Optocoupler (ECG3040) (1) 3.9ΚΩ resistor (1) 220 resistor Introduction An optoisolator is a hybrid integrated circuit that contains an LED on one side...

  • i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due...

    i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT