subject

He following program is the simple i/o sample program (ch8) we discussed in class. basically when you push the button, led1 toggles, and when you release it, led2 toggles. modify the program, so that at the push of the button, the micro cycles through 4 different as follows: 1- led1 flashes while led2 off2- led2 flashes while led1 off3- led1 and led2 flash simultaneously4- led1 and led2 flash alternativelyhint: use a counting semaphore to cycle through 4 different values, each of which corresponds to the four different modes, see the other sample code for flasher with multiple speeds.#include #include "msp430g2553.h"int sw2=0; int main(void){wdtctl = wdtpw | wdthold; //stop watchdog timerp1dir = 0x00; //port 1 all inputsp1dir |= (bit0 | bit6); //set p1.0 and p1.6 as outputs (led1, led2)p1ren |= bit3; //activate resister on p1.3p1out |= bit3; //make it pull up because sw2 is active lowfor (; ; ){sw2 = p1in; //read values from p1sw2 & = bit3; //mask out only bit3 wheresw2 is connectedif (sw2 == bit3){ //if sw2 is highp1out & = ~bit6; //turn led2 offp1out ^= bit0; //toggleled1 __delay_cycles(5); //delay 50,000 micro seconds}else{ //else (sw2 is low)p1out & = ~bit0; //turn led1 offp1out ^= bit6; //toggle led2__delay_cycles(2); //delay 200,000 micro seconds}}// end of infinite loop}//end of main

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:40
1. the program must provide following functions to extract some statistics. note that the data_list parameter specified in these functions may be the same for all functions or different for different functions—that is your choice. a skeleton file is provided on mirmir. a) open_file()prompts the user to enter a year number for the data file. the program will check whether the year is between 1990 and 2015 (both inclusive). if year number is valid, the program will try to open data file with file name ‘year.txt’, where is the year. appropriate error message should be shown if the data file cannot be opened or if the year number is invalid. this function will loop until it receives proper input and successfully opens the file. it returns a file pointer and year. i. hint: use string concatenation to construct the file name b) read_file(fp)has one parameter, a file pointer read. this function returns a list of your choosing containing data you need for other parts of this project. c) find_average(data_list) takes a list of data (of some organization of your choosing) and returns the average salary. the function does not print anything. hints: i. this is not the average of the last column of data. it is not mathematically valid to find an average by finding the average of averages—for example, in this case there are many more in the lowest category than in the highest category. ii. how many wage earners are considered in finding the average (denominator)
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What is the original authority for copyright laws
Answers: 1
question
Computers and Technology, 24.06.2019 03:30
It is not necessary to develop strategies to separate good information and bad information on the internet. true or false
Answers: 1
question
Computers and Technology, 24.06.2019 14:30
Two students are discussing the flow of electricity. student a says that voltage is a measure of the amount of electron flow in a circuit. student b says that power is the product of voltage and current. which of the following statements is correct? a. only student a is correct b. only student b is correct c. both of the two students are correct d. neither of the two students is correct
Answers: 1
You know the right answer?
He following program is the simple i/o sample program (ch8) we discussed in class. basically when yo...
Questions
question
Biology, 07.04.2020 15:50
question
History, 07.04.2020 15:50