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

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

  • I have this case study to solve. i want to ask which type of case study...

    I have this case study to solve. i want to ask which type of case study in this like problem, evaluation or decision? if its decision then what are the criterias and all? Stardust Petroleum Sendirian Berhad: how to inculcate the pro-active safety culture? Farzana Quoquab, Nomahaza Mahadi, Taram Satiraksa Wan Abdullah and Jihad Mohammad Coming together is a beginning; keeping together is progress; working together is success. - Henry Ford The beginning Stardust was established in 2013 as a...

  • It's a weak acid strong base titration Experiment 4: Identification of an unknown acid by titration...

    It's a weak acid strong base titration Experiment 4: Identification of an unknown acid by titration Page 2 of 15 Background In this experiment, you will use both qualitative and quantitative properties to determine an unknown acid's identity and concentration. To do this analysis, you will perform a titration of your unknown acid sample-specifically a potentiometric titration where you use a pH meter and record pH values during the titration, combined with a visual titration using a color indi- cator...

  • Refer to Table 1. Write the Excel formula for each cell marked with “?” in columns B, C and D such that formula could be copied and pasted into columns D, E, F and G using Microsoft Excel without further editing. There is no need to explicitly write the E

    Refer to Table 1. Write the Excel formula for each cell marked with “?” in columns B, C and D such that formula could be copied and pasted into columns D, E, F and G using Microsoft Excel without further editing. There is no need to explicitly write the Excel formula for cells marked with “Copy & paste”. Label each formula clearly with cell reference position. In 2020, BS Bank employs 800 employees in its call centres in the United States...

  • Discussion questions 1. What is the link between internal marketing and service quality in the ai...

    Discussion questions 1. What is the link between internal marketing and service quality in the airline industry? 2. What internal marketing programmes could British Airways put into place to avoid further internal unrest? What potential is there to extend auch programmes to external partners? 3. What challenges may BA face in implementing an internal marketing programme to deliver value to its customers? (1981)ǐn the context ofbank marketing ths theme has bon pururd by other, nashri oriented towards the identification of...

  • The discussion: 150 -200 words. Auditing We know that computer security audits are important in business....

    The discussion: 150 -200 words. Auditing We know that computer security audits are important in business. However, let’s think about the types of audits that need to be performed and the frequency of these audits. Create a timeline that occurs during the fiscal year of audits that should occur and “who” should conduct the audits? Are they internal individuals, system administrators, internal accountants, external accountants, or others? Let me start you: (my timeline is wrong but you should use some...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

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