Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C which will prompt the user to input control commands and then create a 16-bit integer which will be suet to

Write a program in C which will prompt the user to input control commands and then create a 16-bit integer which will be suet to write the 16-bit port.

The program should accept the following commands to control the four two-line modules:

Light Off Bits 14 and 15 of PortB should be cleared. (00)

Light Dim - Bit 14 of PortB should be set and bit 15 cleared. (01)

Light Bright - Bits 14 and 15 of PortB should be set. (11)

Heater Off - Bits 12 and 13 of PortB should be cleared. (00)

Heater Warm - Bit 12 of PortB should be set and bit 13 cleared. (01)

Heater Hot - Bits 12 and 13 of PortB should be set. (11)

Compressor Off - Bits 2 and 3 of PortB should be cleared. (00)

Compressor Cool - Bit 2 of PortB should be set and bit 3 cleared. (01)

Compressor Cold - Bits 2 and 3 of PortB should be set. (11)

Fan Off - Bits 0 and 1 of PortB should be cleared. (00)

Fan Low - Bit 0 of PortB should be set and bit 1 cleared. (01)

Fan High - Bits 0 and 1 of PortB should be set. (11)

Four more possible inputs are Reset, Init 0xnnnn, Help, and Quit

For the Mode mode_number command, the BCD value of mode_number should be written to Bits 4 through 11 of PortB.

When bits are written to PortB for each command, only those bits being written should be affected, and no other bits of PortB should be changed.

If Reset is input, all bits in PortB should be cleared.

The following command should also be available

Init 0xnnnn Initializes the system to the 16-bit hex value given by 0xnnnn and then displays the settings.

If Help is input, the program should print valid commands with their syntax.

And if Quit is input, the program should exit.

As stated, for each iteration of the main loop, the program should print the value of PortB in both hexadecimal and binary, where the bits for the binary value are labeled from Bit 15 down to Bit 0.

This program should not use strings or arrays, only bitwise operators

image text in transcribed

MCU Fan Unit Compressor Unit Ports System Control Unit Heating Unit Lighting Unit MCU Fan Unit Compressor Unit Ports System Control Unit Heating Unit Lighting Unit

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

How can gifts be used to lower the overall tax paid by a family?

Answered: 1 week ago