Question

In: Electrical Engineering

Write C18 program to get bit RB3 and send it to RC2.

Write C18 program to get bit RB3 and send it to RC2.

Solutions

Expert Solution

 #include <p18f452.h>
 #include <stdio.h>
 #pragma config WDT = OFF
  
 void main(void)
 {
 int b0=0,b1=0,b2=0,b3=0,b4=0,b5=0,b6=0,b7=0;  // Individual pin value variables.
 int c0=0,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c7=0;
 
      TRISC = 0;  //PORT C = output configuration of port C.
      TRISB = 1;  //PORT B = input configuration of Port B.
 PORTB = 0x8;  // So RB3 bit is set on INPUT.
 b0 = PORTBbits.RB0;  // Each input bit is assigned a seperate variable
 b1 = PORTBbits.RB1;
 b2 = PORTBbits.RB2;
 b3 = PORTBbits.RB3;
 b4 = PORTBbits.RB4;
 b5 = PORTBbits.RB5;
 b6 = PORTBbits.RB6;
 b7 = PORTBbits.RB7;
     printf("\n INPUT %d,%d,%d,%d,%d,%d,%d,%d", b7,b6,b5,b4,b3,b2,b1,b0);
 PORTC= 59H; //so RC2 is set as output.
 c0 = PORTCbits.RC0;  // Each output bit is assigned a seperate variable.
 c1 = PORTCbits.RC1;
 c2 = PORTCbits.RC2;
 c3 = PORTCbits.RC3;
 c4 = PORTCbits.RC4;
 c5 = PORTCbits.RC5;
 c6 = PORTCbits.RC6;
 c7 = PORTCbits.RC7;
      printf("\n OUTPUTS %d,%d,%d,%d,%d,%d,%d,%d", c7,c6,c5,c4,c3,c2,c1,c0);
while (1); 
 }
  

Related Solutions

Write a program using interrupts to get data serially and send it to P2 while at...
Write a program using interrupts to get data serially and send it to P2 while at the same time Timer 0 is generating a square wave of 5 kHz. We've been basing our code on the Intel 8051 microntroller and assembly language.
Write the Bit configuration of PSW( The Program Status Word ).
Write the Bit configuration of PSW( The Program Status Word ).  
Write a program sequence that will test the byte STATUS and branch to ROOTINE_1 if bit...
Write a program sequence that will test the byte STATUS and branch to ROOTINE_1 if bit 1, 2 or 4 is 1. Otherwise, it is branch to ROUTINE_2 if both bits 1 and 3 are 1 and to ROUTINE_3 if both bits 1 and 3 are 0. In all other cases it is to exeute ROUTINE_4. Assume that the routines are more than 128 bytes long. Also give a flowchart of the sequence.
Write an assembly language program code to clear and set bit 7th and 19th in a...
Write an assembly language program code to clear and set bit 7th and 19th in a 32-bit variable called N.
Write a MIPS program that always checks the bit 0 of a memory data at address...
Write a MIPS program that always checks the bit 0 of a memory data at address 0x0BF81234. If it is equal to one add nth and (n+1)th elements of an array and store it to memory address 0x0BF85678 . Suppose $t0 contains the address of the 0th element of an array of 32-bit data and $t1 = n.
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
In Python, write a program to get a positive integer n from keyboard first (your program...
In Python, write a program to get a positive integer n from keyboard first (your program must be able to check the validation of n being positive), and then get n integers from keyboard and store these n integers in a list. Do some processing, and print out average of the elements in the list at end of your program. For example, suppose user enters 3 first (n = 3), which means we get another three integers from the user....
Write a complete java program to get input of a person’s age and their years of...
Write a complete java program to get input of a person’s age and their years of current USA citizenship. Tell them if they are eligible to run for US House of Representatives, US Senate, or President. At first, have the program just run once and give the answer for the given inputs. Give the answer in a nice format and be clear which offices the person can run for. Write good and complete pseudo code. Next, put that program in...
using Windows 32 bit framework , Write an assembly language program to find the second minimum...
using Windows 32 bit framework , Write an assembly language program to find the second minimum element (formally, second minimum is larger than the minimum but smaller than all the other elements in the array) of an array of size 100. Note: You can define the array as nbrArray DWORD 23 45 21 67 78 95 dup(?) and show that your program works for the first five elements. Display the second minimum in a message box using Input output macro
Write a program that converts a given floating point binary number with a 24-bit normalized mantissa...
Write a program that converts a given floating point binary number with a 24-bit normalized mantissa and an 8-bit exponent to its decimal (i.e. base 10) equivalent. For the mantissa, use the representation that has a hidden bit, and for the exponent use a bias of 127 instead of a sign bit. Of course, you need to take care of negative numbers in the mantissa also. Use your program to answer the following questions: (a) Mantissa: 11110010 11000101 01101010, exponent:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT