Question

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

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

  1. 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?
  1. A variable called count has the value 20. What value does it have after the following statement has been executed?

count = count >> 2;

  1. There is a difference between logical operators(!, || , &&) and bitwise operators (~, |, &). What values does portb have after the following statements are executed.

portb = 0x01 || 0x06;

portb = 0x01 | 0x06;

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

Answer :-

portb = 0x47; i.e. in binary it is 0100_0111 hence pins 3, 4, 5 and 7 will have zero voltage and pins 0, 1, 2 and 6 will have voltage label as Vcc.

portb = 47; i.e. in binary it is 0010_1111 hence pins 4, 6 and 7 will have zero voltage and pins 0, 1, 2, 3 and 5 will have voltage label as Vcc.

portb = 11b; hence pins 0 and 1 will have Vcc and rest all pins have zero potential.

portb = 101;i.e. in binary it is 0110_0101 hence pins 1, 3, 4 and 7 will have zero voltage and pins 0, 2, 5 and 6 will have voltage label as Vcc.

portb= 0b01010101; pins 0, 2, 4 and 6 have Vcc and 1, 3, 5 and 7 will have zero voltage label.

  1. If a variable called my_counter is declared as follows:- unsigned char my_counter;
  • How many bytes of RAM will the variable occupy? unsigned char have one byte of memory.
  • What is the minimum and maximum values the variable could have? minimum when all 8-bits are zero in one byte so minimum value is zero. Maximum when all 8-bits are 1 i.e. 1111_1111 in binary. Hence 255 in decimal.
  1. A variable called count has the value 20. What value does it have after the following statement has been executed?

count = count >> 2; This operation on count will make count to be divisible by 2 as right shift operation is equivalent of divide by two. Thus count = 10.

  1. There is a difference between logical operators(!, || , &&) and bitwise operators (~, |, &). What values does portb have after the following statements are executed.

portb = 0x01 || 0x06;

portb will have value equal to 0x01 since logical operator gives either 0 or 1. Here 0x01 and 0x06 are non-zero numbers, so logical operator will give 1, hence portb = 0x01.

portb = 0x01 | 0x06;

here bitwise ORed value of 0x01 and 0x06 will be stored in variable portb. 0x01 = 0000_0001 and 0x06 = 0000_0110. The bitwise ORed value is 0000_0111 i.e. 0x07 in hex, hence portb = 0x07.

Add a comment
Know the answer?
Add Answer to:
State the voltages you expect to appear on PORTB pins(7 to 0) in each of the...
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 programming lab: Description: In this lab you will write a program that will contain two...

    C programming lab: Description: In this lab you will write a program that will contain two functions, setlsbs() and getlsbs(). These functions will use bitwise operators to embed and extract "hidden" bits in a character array. Write a program to test your functions as follows: Obtain a random number seed from the command line of your program using command line arguments. Initialize an array p of 8 unsigned char with random numbers from 0 to 255 Initialize a separate unsigned...

  • Problem 1 1 def modify(word.ch). word == word + ch return word print('new word is', word)...

    Problem 1 1 def modify(word.ch). word == word + ch return word print('new word is', word) To run the function modify() defined above, we make the following call: result = modify('course', 's') Find and fix the errors in the function definition, lines (1) to (4), such that after the call is executed: • Variable result has the value 'courses' • 'new word is courses' is printed out. For each error found and fixed, you must indicate the following: • line...

  • Objectives You will implement and test a class called MyString. Each MyString object keeps track ...

    Objectives You will implement and test a class called MyString. Each MyString object keeps track of a sequence of characters, similar to the standard C++ string class but with fewer operations. The objectives of this programming assignment are as follows. Ensure that you can write a class that uses dynamic memory to store a sequence whose length is unspecified. (Keep in mind that if you were actually writing a program that needs a string, you would use the C++ standard...

  • I've posted 3 classes after the instruction that were given at start You will implement and...

    I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...

  • Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be...

    Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...

  • Don't attempt if you can't attempt fully, i will dislike and negative comments would be given...

    Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...

  • These are my answere to the following questions: are they right? 1. B 2. T 3....

    These are my answere to the following questions: are they right? 1. B 2. T 3. T 4. T 5. F 6. T 7. A 8. D 9. E 10. B 11. B 12. A 13. A 14. D 15. C 16. D 17. T 18. C 19. T 20. T 21. T 22. A 23. T 24. D 25. B 26. A 27. A 28. A 29. T 30. C 31. D 32. A 33. T 34. F 35....

  • Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C -...

    Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...

  • Edit a C program based on the surface code(which is after the question's instruction.) that will...

    Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....

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

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