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.
Write a Python Client/Server Socket Program that will allow you to send text messages between the...
Write a Python Client/Server Socket Program that will allow you to send text messages between the server and client, terminating when the exit is typed on the client. Build the program on your 2-VM’s and get it working. Cut and paste your code below along with screen shots of your program working.
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
Write a program in NASM that turns a 32-bit numeric value (e.g., 0xFFFFh) and converts it...
Write a program in NASM that turns a 32-bit numeric value (e.g., 0xFFFFh) and converts it to a byte array such that it can be printed to the screen using a system call method. A loop is necessary for converting the numeric value to ASCII for output. Again, use a system call (e.g., int 80h) to print the value to the console. Calling external functions (e.g. printf) is not allowed. You may use the starter file attached to this assignment.
C++ (data structure using c++). please send me copyable file. Write a program and test a...
C++ (data structure using c++). please send me copyable file. Write a program and test a program that translates the following Bubble Sort algorithm to a bubblesort function. The function's prototype is, void bubblesort(int a[], int size); Bubble Sort The inner loop moves the largest element in the unsorted part of the array to the last position of the unsorted part of the array; the outer loop moves the last position of the unsorted part of the array. The Bubble...
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....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT