Question

In: Electrical Engineering

Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR...

Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR (exclusive OR)” of these two bits and write the result of the “XOR operation” to bit 4 of Port-D.

Solutions

Expert Solution

As you haven't notified the Microcontroller's name and mentioned about PortC and PortD, I assume that you are talking about the PIC controller. The code for which is explained below.

#include<> //Add the appropriate PIC header file, corresponding to the one you are using.

void main()

{

ANSEL=0; // For configuring the pins as digital pins

ANSELH=0;

PORTC =0; //Clearing the C pins

TRISC=0xFF; //Configuring PORTC as input port

PORTD=0; //Clearing D pins

TRIS D=0b1110111; //Configuring PORTD's pin 4 as output

sbit A at RC4_bit; // Getting 4th pin of PortC

sbit B at RC7_bit;   // Getting 7th pin of PortC

sbit C at RD4_bit; // Accessing 4th pin of Port D

C= A^B; //Bitwise XOR operator is used

}

Keep in mind that TRIS pin has to be set to 0 or 1 to set the port as output or input respectively.

After which you have to access the individual bits and perform required actions on them.

Even if it is a different microcontroller, Follow similar steps to arrive at your answer. The syntax may change but the concept is the same.


Related Solutions

. Write a program which encodes any string using the XOR instruction.  Test it using your <first...
. Write a program which encodes any string using the XOR instruction.  Test it using your <first name last name> in the data segment to produce cipher text and then decode using the program to get plain text.  Use the last two digits of your student id as the key.  Print plane text from the data segment, print the cipher text, and then print the plain text upon execution.  Submit the asm/list file and screenshots that shows the output of your code. What are...
Construct an even parity Hamming code with a total of 7 bits (4 data bits and...
Construct an even parity Hamming code with a total of 7 bits (4 data bits and 3 check bits).
Complete the matrix below (use 4 bits) Signed Integer Signed Magnitude 1’s Complement 2’s Complement Excess-7...
Complete the matrix below (use 4 bits) Signed Integer Signed Magnitude 1’s Complement 2’s Complement Excess-7 5 -3
Complete the matrix below (use 4 bits) Signed Integer Signed Magnitude 1’s Complement 2’s Complement Excess-7...
Complete the matrix below (use 4 bits) Signed Integer Signed Magnitude 1’s Complement 2’s Complement Excess-7 5 -3
Compute the following operations using 8-bits 2’s complement encoded numbers: a. 127-47 b. 47-56 c. 19-120
Compute the following operations using 8-bits 2’s complement encoded numbers: a. 127-47 b. 47-56 c. 19-120
in verilog if i have a hex number how do i get a specific 4 bits?...
in verilog if i have a hex number how do i get a specific 4 bits? for exampe if i have a hex number 5055 how do i get the last four bits which would be 0101?
Write the C code required to configure pin 0 on port B to be an input...
Write the C code required to configure pin 0 on port B to be an input with the pullup resistor enabled.
Directions: You are to write a C++ program that meets the instruction requirements below. Deliverables: ·...
Directions: You are to write a C++ program that meets the instruction requirements below. Deliverables: · Your C++ source code file. (The file with the .CPP extension).No other files will be accepted. A screenshot of your program running. Program Instructions: Consider the following incomplete C++ program: #include int main() { … } 1. Write a statement that includes the header files fstream, string, and iomanip in this program. 2. Write statements that declare inFile to be an ifstream variable and...
7 – For the following operations: • write the operands as 4-bit 2's complement binary numbers,...
7 – For the following operations: • write the operands as 4-bit 2's complement binary numbers, • perform the operation shown, • show all work in binary operating on 4-bit numbers, and • identify overflow if necessary. a) 4 + 2 b) 4 – 2 c) 2 – 4 d) 4 + 4
1.Using C++ code, write a program named q4.cpp to compute the product (multiplication) of 4 integers...
1.Using C++ code, write a program named q4.cpp to compute the product (multiplication) of 4 integers a, b, c and d, where a is input by a user via the keyboard, b = 2a - 1, c = ab - 2 and d = |a - b - c|. 2.Using C++ code, write a program named q5.cpp to solve the equation 2n = 14.27 for n. 3.Using C++ code, write a program named q3.cpp to divide each of the elements...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT