Question

In a C program for a microcontroller, portb has been setup as all outputs and is...

  1. In a C program for a microcontroller, portb has been setup as all outputs and is assigned the hexadecimal value 0xC6. Determine the voltage levels on the pins of portb.

  1. In the context of explaining the difference between the logical NOT operator(!) and the bitwise NOT operator(~) say what value portb will end up with in each of the following cases:-
  1. portb = ~ (0x45);
  2. portb = !(0x45);
  1. Determine the value on the portb pins after the following C code statement is executed, if portb had an initial value of 0x52:-

portb = portb >> 2;

  1. In the context of explaining the difference between the logical AND operator(&&) and the bitwise AND operator(&) say what value portb will end up with in each of the following cases, if the initial value of portb is 0x77:-
  1. portb = portb & 0x0F;
  2. portb = portb && 0x0F;
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer :- i) Value is 0xC6 = 1100_0110 so

pin0 = 0 V
pin1 = Vcc
pin2 = Vcc
pin3 = 0 V

pin4 = 0 V
pin5 = 0 V
pin6 = Vcc
pin7 = Vcc

Answer :- ii)a) ~(0x45) = ~(0100_0101) = 1011_1010 = 0xBA. So portb = 0xBA
b) !(0x45) = 0x00 since logical NOT of non-zero is zero. So portb = 0x00.

Answer :- iii) (0x52 >> 2) = (0101_0010 >> 2) = 0001_0100 = 0x14. Thus portb = 0x14.

Answer :- iv)a) (0x77 & 0x0F) = (0111_0111) & (0000_1111) = 0000_0111 = 0x07. Thus portb = 0x07.
b) 0x77 && 0x0F = 0x01, logical operators give result either 0 or 1. Since here both operands are non-zero so logical AND of them will be logic 1.

Add a comment
Know the answer?
Add Answer to:
In a C program for a microcontroller, portb has been setup as all outputs and is...
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
  • 1- Explain the function of the ‘trisb’ Special Function Register(SFR). Where is it located in the...

    1- Explain the function of the ‘trisb’ Special Function Register(SFR). Where is it located in the PIC. Say what effect the following statement has:- trisb = 0x03; 2- In a C program for a microcontroller, portb has been setup as all outputs and is assigned the hexadecimal value 0xD3. Determine the voltage levels on the pins of portb. 3- In the context of explaining the difference between the logical NOT operator(!) and the bitwise NOT operator(~) say what value portb...

  • State the voltages you expect to appear on PORTB pins(7 to 0) in each of the...

    State the voltages you expect to appear on PORTB pins(7 to 0) in each of the following cases: portb = 0x47; portb = 47; portb = 11b; portb = 101; portb= 0b01010101; If a variable called my_counter is declared as follows:- unsigned char my_counter; How many bytes of RAM will the variable occupy? What is the minimum and maximum values the variable could have? A variable called count has the value 20. What value does it have after the following...

  • Write a c++ program in that file to perform a “Search and Replace All” operation. This...

    Write a c++ program in that file to perform a “Search and Replace All” operation. This operation consists of performing a case-sensitive search for all occurrences of an arbitrary sequence of characters within a file and substituting another arbitrary sequence in place of them. Please note: One of the biggest problems some students have with this exercise occurs simply because they don’t read the command line information in the course document titled “Using the Compiler’s IDE”. Your program: 1. must...

  • I need this in C++. This is all one question Program 2: Linked List Class For...

    I need this in C++. This is all one question Program 2: Linked List Class For this problem, let us take the linked list we wrote in a functional manner in a previous assignment and convert it into a Linked List class. For extra practice with pointers we'll expand its functionality and make it a doubly linked list with the ability to traverse in both directions. Since the list is doubly linked, each node will have the following structure: struct...

  • C++ PROGRAM ONLY! For this lab you need to write a program that will read in...

    C++ PROGRAM ONLY! For this lab you need to write a program that will read in two values from a user and output the greatest common divisor (using a recursive implementation of the Euclidean algorithm) to a file. In Lab #3, you implemented this program using an iterative method. Greatest Common Divisor In mathematics, the greatest common divisor (GCD) of two or more integers (when at least one of of them is zero then the larger value is the GCD....

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

  • Exercise #1: Write a C program that contains the following steps (make sure all variables are...

    Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. Commenting out the existing coding, write the code to divide a...

  • III. ASSIGNMENT 2.1 As discussed in class, the example program enumerates all possible strings (or if...

    III. ASSIGNMENT 2.1 As discussed in class, the example program enumerates all possible strings (or if we interpret as numbers, numbers) of base-b and a given length, say l. The number of strings enumerated is b l . Now if we interpret the outputs as strings, or lists, rather than base-b numbers and decide that we only want to enumerate those strings that have unique members, the number of possible strings reduces from b l to b!. Furthermore, consider a...

  • LC-3 Programming Help!! The Stack Protocol The following outline is the protocol for passing arguments to...

    LC-3 Programming Help!! The Stack Protocol The following outline is the protocol for passing arguments to a function and returning values. Everything is stored on the runtime stack so that space is used only when the function is executing. As a result the actual address of arguments and locals may change from call to call. However, the layout of the stack frame (activation record) is constant. Thus, the offests from the frame pointer (FP) to the parameters/locals are constant. All...

  • 1.  Tim Smith is shopping for a used luxury car. He has found one priced at...

    1.  Tim Smith is shopping for a used luxury car. He has found one priced at $36,000. The dealer has told Tim that if he can come up with a down payment of $5,500​, the dealer will finance the balance of the price at a 8​% annual rate over 2 years (24 months).  ​(Hint: Use four decimal places for the monthly interest rate in all your​ calculations.) a.  Assuming that Tim accepts the​ dealer's offer, what will his monthly​ (end-of-month)...

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