Question

In: Computer Science

Q2. Answer the following questions about the program. Describe the purpose of the ports and pins...

Q2. Answer the following questions about the program.

Describe the purpose of the ports and pins being used in the above example.

Describe the effect of changing PinPull_Up to PinPull_None

Describe the effect of changing PinPull_Up to PinPull_Down

Do we need PinDriveStrength_High? Carefully examine the LED board to help in answering this.

Find where Led::setOutput() method is declared and determine the default parameters used if no actual parameters are specified.

A little bit tricky!

Hint: If you move the cursor to a method and then press F3 an editor window will open at the method declaration.

Find where Switch::setInput() method is declared and determine the default parameters used if no actual parameters are specified.

Also a little bit tricky!

Find where GpioC<...> is declared and determine the default template parameters. Which defaults have been used in the example?

THE CODE IS BELOW:

#include "hardware.h"

using namespace USBDM;

using Switch = GpioC<0, ActiveLow>;

using Led     = GpioC<1, ActiveHigh>;

using RedLed = GpioC<3, ActiveLow>;

using BlueLed = GpioA<2, ActiveLow>;

int main() {

   Led::setOutput(

         PinDriveStrength_High,

         PinDriveMode_PushPull,

         PinSlewRate_Fast);

   RedLed::setOutput(

               PinDriveStrength_High,

               PinDriveMode_PushPull,

               PinSlewRate_Slow);

   BlueLed::setOutput(

               PinDriveStrength_High,

               PinDriveMode_PushPull,

               PinSlewRate_Slow);

   Switch::setInput(

         PinPull_Up,

         PinAction_None,

         PinFilter_None);

   for(;;) {

      bool switchValue = Switch::read();

      console.write("Switch is ").writeln(switchValue);

      Led::write(switchValue);

      RedLed::write(!switchValue);

      BlueLed::write(switchValue);

   }

   return 0;

}

Solutions

Expert Solution

1- As the Pins are been set on which they will set the On and Off function as in code we set the pins to do High and Low

2-Pin pull Up will pass the current and it is been the state of ON while the Pin Pull None will be NOTHING as there is only ON button

3- Pin pull Up will pass the current and it is been the state of ON while the Pin Pull Down will be zero as it is the state of OFF

4-Yes it is important as to keep the strength high as we will also be using the resistor.

5- The Led Output() has the default parameters pins drive rate ,strength rate and slew rate.

6- AS it is been called through the library of switch and the default paramerters that are been passed are been listed below

         PinAction_None,

         PinFilter_None);

7- As it is been Red led out put result and active low are been passed as parameter

PLEASE GIVE A THUMBS UP!!!!!!!!1


Related Solutions

Answer the following questions: Q1. Describe the applications of elasticity in various fields. Q2. Imagine you...
Answer the following questions: Q1. Describe the applications of elasticity in various fields. Q2. Imagine you are owner of a fast food joint in Bahrain. What are the challenges you faced during Covid-19 pandemic? How will you overcome challenges in order to sustain business? Q3. How does the change in determinants of supply reflect in the shift of supply curve? Draw appropriate diagram.
About the Female Reproductive System and development. answer the following questions: Briefly describe the development of...
About the Female Reproductive System and development. answer the following questions: Briefly describe the development of an egg, oogenesis, in the female reproductive system including the various hormones involved in the process. This may take 5-6 sentences to properly cover the main parts. What is the role of estrogen and progesterone in the development and ovulation of a secondary oocyte? On average, a woman's cycle occurs every 28 days. Describe and differentiate what is happening during the proliferative phase and...
Answer the following questions about variability of data sets: How would you describe the variance and...
Answer the following questions about variability of data sets: How would you describe the variance and standard deviation in words, rather than a formula? Think of what you are calculating and how it might be useful in describing a variable. What is the primary advantage of using the inter-quartile range compared with the range when describing the variability of a variable? Can the standard deviation ever be larger than the variance? Explain. Can the variance ever be negative? Why or...
In about 200 words (total), answer one of the following questions: Describe the two distinct obligations...
In about 200 words (total), answer one of the following questions: Describe the two distinct obligations incurred by a corporation when issuing bonds. Explain the meaning of each of the following terms as they relate to a bond issue: (a) convertible and (b) callable. If bonds issued by a corporation are sold at a discount, is the market rate of interest greater or less than the contract rate?
Given the following program below answer the following questions. 1.Draw a program flow graph for the...
Given the following program below answer the following questions. 1.Draw a program flow graph for the binsearch() function 2. Find the Define and Usage node, du-paths and dc-paths for all the variables int binsearch(int x,int v[],int n) { int low,high,mid; low=0; high=n-1; while(low<high) { mid = ( low + high ) / 2; if( x < v[mid]) high = mid - 1; else if ( x > v[mid]) low = mid + 1; else return mid; } return -1; }
Based on the article pasted below please answer the following questions: 1. The purpose of the...
Based on the article pasted below please answer the following questions: 1. The purpose of the article or problem statement 2. A brief summary of the literature review 3. What are the research questions or hypotheses relevant to "How color affects one's mood"? 4. A basic description of the design/methodology of the research study (if applicable) 5. A report of the findings of the article, and, 6. the value or use of the article in relation to a research project...
The following questions use the table below on soybean oil. Answer the following questions about an...
The following questions use the table below on soybean oil. Answer the following questions about an end user needing to purchase soybean oil. One soybean oil contract is 60,000 pounds (lbs). Now Later Cash Soybean Meal Market $0.335/lb $0.346/lb Futures Soybean Meal Market $0.3000/lb $0.311/lb 1) Is the individual concerned about price increasing or decreasing? 2) What is the initial action in the futures market: buy or sell? 3) What is the cash price paid/received by the individual later? 4)...
2) Answer each of the following: a) Describe the purpose and mechanism of action for aldosterone....
2) Answer each of the following: a) Describe the purpose and mechanism of action for aldosterone. b) Describe how changes in osmolarity and blood pressure and volume are regulated by angiotensin and atrial natiuretic peptide. c) Describe how pH is maintained in the proximal and distal tubules of the kidneys. Thank you
Q1. What is the purpose of a Journal and a Ledger? (1M) Q2. The following are...
Q1. What is the purpose of a Journal and a Ledger? (1M) Q2. The following are account balances (in thousands) of International Medical Service Center. Prepare a statement of operations for the year ended December 31, 2018 (4M) Net property and equipment SAR 2,000 Accounts receivable SAR2,000 Medical claims payable SAR45,000 Patient service revenue (net of contractuals) SAR 950,000 Supply expense SAR 255,000 Net assets released from restriction for operations SAR 45, 000 Depreciation expense SAR 35,000 Transfer to parent...
Answer the following questions about sampled-current voltammetry. #1 describe the difference between a charging current and...
Answer the following questions about sampled-current voltammetry. #1 describe the difference between a charging current and Faradaic current. #2 Explain why you should wait for a few seconds before applying the voltage and measuring the current in the sampled-current voltammetry.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT