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 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.
. 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
1. Obtain the 1’s complement, 2’s complement and sign magnitude system representation in 7 bits for...
1. Obtain the 1’s complement, 2’s complement and sign magnitude system representation in 7 bits for the following decimal numbers: a) 1510 b) -2110 c) 3510 d) -2710 2. Use 1’s and 2’s complement system to perform the following calculations and mention if there will be overflow or not: a) 1100 – 0101 b) 1010 + 0100 c) 01100 + 00111
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.
Write a C program that accepts a port number as a command line argument, and starts...
Write a C program that accepts a port number as a command line argument, and starts an HTTP server. This server should constantly accept() connections, read requests of the form: GET /path HTTP/1.1\r\n\r\n read the file indicated by /path, and send it over the "connect" file descriptor returned by the call to accept().
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT