Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

Prove that the linear equation system x1 + 3x2 = c1 x1 - x2 = c2

Answered: 1 week ago

Question

2. Be tactful, but dont avoid talking about tough issues.

Answered: 1 week ago

Question

Describe employee assistance programs.

Answered: 1 week ago

Question

Describe the importance of physical fitness programs.

Answered: 1 week ago

Question

Discuss the factors that set the stage for global HR practice.

Answered: 1 week ago