Question: Question 5: Bitwise Operations a) Write a single line of Ccode to implement each of the following, given these declarations: unsigned char ch unsigned short

 Question 5: Bitwise Operations a) Write a single line of Ccode

to implement each of the following, given these declarations: unsigned char ch

Question 5: Bitwise Operations a) Write a single line of Ccode to implement each of the following, given these declarations: unsigned char ch unsigned short n Example: For ch, check if bit 0 is set to 1 if (ch &0x01) Remember, try to perform the operation with a single line of C code. You can start with more than one line of code if needed, but then try to combine operations into a single expression. i. Set bits 5, 4,0 of ch to 1, and preserve the remaining bits. i. For ch,check if any of bits 6,3, 2 are set to 1 ii. For n, set bits 15 and 11 to 1, clear bits 7 and 5 to 0, toggle bits 3 and 14, and preserve the remaining bits b) For each C code fragment, give the final value of the indicated variable after the code fragment is run. Ifthe final value cannot be determined, then give NA. in hex) i. Final value of ch is char ch-0x3B ch-ch> 3 short ptrt+ c Which line of C code is a friendly way to set Port B bit 2 (PB2 1) assuming this pin has already been initialized as an output? GPIO PORTB DATA R-0x00 GPIO PORTB DATA R-0x02 GPIO PORTB DATA R 0x04 GPIOPORTBDATAR 1-0x02; GPIO PORTB DATA R I-0x04 GP10PORTBDATAR &-0x02; GPIO PORTB DATA R&0x04 GPIO PORTB DATA R-0x02 GPIO PORTB DATA R 0x04 - - - - - - d) Which line of C code is a friendly way to clear Port B bit 2 (PB2 0) assuming this pin has a lready been initialized as an output? GPIO PORTB DATA R-0x00 GPIO PORTB DATA R-0x02 GPIO PORTB DATA R 0x04 GPIOPORTBDATAR 1-0x02; GPIO PORTB DATA R I-0x04 GP10PORTBDATAR &-0x02; GPIO PORTB DATA R&0x04 GPIO PORTB DATA R-0x02 GPIO PORTB DATA R 0x04

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!