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.

Hope you understood the solution :)


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
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().
Q1- Write code in C language(Atmel atmega32 avr microcontroller) (a)-Switches are connected to Port C and...
Q1- Write code in C language(Atmel atmega32 avr microcontroller) (a)-Switches are connected to Port C and Port B and LED’s with PORTD. Write a code to read input from PortB and C and perform following. Addition of both inputs, Subtraction, Multiplication, Division, And, Or, Nor,Xor. (b)- A switch is connected to PD0 and LED’s to Port B and Port C. Write a code to perform following: When switch is 0 send your roll number to Port B. When Switch is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT