Question

Hello Everyone .

I hope you are doing well .

This is my question :

Question I: Write a C-program to receive a character from a PC to PIC16F877a Microcontroller with a baud rate 19200 and a fre

THANK YOU.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution :-

Note : Check attached image for simulation output.

Simulation tested in Proteus ISIS. Code compiled in MPLAB IDE.

Program Plan :

first set uart at baudrate 19200 .

check data available or not if available send data to PORTD .

Proteus Connection :

Connect virtual port to virtual terminal .

connected virtual terminal RX in to RX pin of microcontroller

connect 8 led to PORTD so we can see output on LED and virtual terminal

I am program a PIC board to send a character each second 'A' connected to COM3 so virtual port will take data at COM3.

Program :-

#include <xc.h> // x c 8 compiler

#include <pic16f877a.h>

#define _XTAL_FREQ 10000000 // uC frequency 10 mhz

char uartInit(long int baudRate);

char uartRxAvailable(void);

char serialReceive(void);

void main()

{

TRISD = 0x00; //PORTD as Output

uartInit(19200); //start uart at baud rate 19200

do

{

if(uartRxAvailable()) //check if data available

PORTD=serialReceive(); //receive char and send it to PORTD

__delay_ms(500);

PORTD=0x00; //set all led low on PORTD

}while(1);

}

char uartInit(long int baud)

{

//F_CPU= uC FREQUENCY

unsigned int value;

//BAUDRATE = XTAL(64(x+1)) //XTAL=10mhz

value = (_XTAL_FREQ - baud*64)/(baud*64);

if(value>255)

{

// if value more than 255 than enable high speed uart

//so baud=FOSC/16(x+1)

value = (_XTAL_FREQ - baud*16)/(baud*16);

SPBRG=value;

BRGH = 1; //enable high speed uart baud rate

}

if(value<256)

{

SPBRG = value;

SYNC = 0; //0 means asynchronous mode of uart

SPEN = 1; //enable uart

TRISC7 = 1; //pin rc7 as uart comm.

TRISC6 = 1;

CREN = 1; //enable rx pin

TXEN = 1; //enable tx pin

return 1;

}

return 0;

}

char uartRxAvailable(void)

{

return RCIF; //if RCIF flag is set means data is available

}

char serialReceive(void)

{

while(!RCIF); //wait for flag clear and get data from rx register

return RCREG;

}

Schematic :-

P1 RXD TXD U1 13 14 RTS OTOTOTOTO 10.0.0.0 1 6 DCD DSR 2 RXD 7 RTS 3 TXD 8 CTS 4 DTR 9 RI 5 ERROR O COMPIM D1 <TEXT 33 34 35====== 。 RE:20 RBA EI Virtual Terminal 促度問 AAAAAAAAAAAAA LE =

Add a comment
Know the answer?
Add Answer to:
Hello Everyone . I hope you are doing well . This is my question : THANK...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • hello how are you ? I hope you are doing well can you please help me...

    hello how are you ? I hope you are doing well can you please help me to understand what is western bolting by writing a summary that describe a situation where you would need this technique and the steps of the procedure or how it works. thank you so much

  • hope you are safe and well! i was doing my practice questions and I got stuck,...

    hope you are safe and well! i was doing my practice questions and I got stuck, thank you so much in advance! [Practice Question 4] The following two statements, and prove it by CONTRADIC-TION. You need to clearly mark your choice. Remember to clearly mark your choice, and to write every step of your proof clearly. (A) Suppose n € Z, if n3 + 5 is odd, then n is even. (B) Suppose a, b, c e Z, if alb...

  • hello i am doing a research paper for my economic class about that question if you...

    hello i am doing a research paper for my economic class about that question if you guys can provide with some good paragraphs preferable own words and no internet I would really appreciate it thanks in advance. in what ways income inequality affects poverty?

  • Hi! I hope to receive help with the following question and I thank you in advance!...

    Hi! I hope to receive help with the following question and I thank you in advance! I will give you a thmbs up! ---------------------------- 2) It is known that when the price of a good is £2, 50 units are demanded, but when the price increases to £4 the quantity demanded drops to 45 units (that is, a line contains the points (2, 50) and (4, 45)). a) Calculate the change in demand that results from a 1 unit increase...

  • Hello. I am using a Java program, which is console-baed. Here is my question. Thank you....

    Hello. I am using a Java program, which is console-baed. Here is my question. Thank you. 1-1 Write a Java program, using appropriate methods and parameter passing, that obtains from the user the following items: a person’s age, the person’s gender (male or female), the person’s email address, and the person’s annual salary. The program should continue obtaining these details for as many people as the user wishes. As the data is obtained from the user validate the age to...

  • Hello, I need help with the following question in MATLAB for digital image processing, thank you ...

    Hello, I need help with the following question in MATLAB for digital image processing, thank you for your help in advance Convolution operations using mask are commonly applied in image enhancement. Even edge detection is based on convolution with a specially designed mask. The assignment here is to write your own function for convolution and test it in edge detection. 1. Write a function in Matlab as follows: function Img2 Convolution(Img, mask); %Input: Img is the original image data matrix,...

  • /*hello everyone. my question is mostly related to the garagetest part of this assignment that i've...

    /*hello everyone. my question is mostly related to the garagetest part of this assignment that i've been working on. i am not sure how to read the file's contents AND put them into variables/an array. should it be in an arraylist? or maybe a regular array? or no arrays at all? i am also not sure how to call the factory method from garagec. i'm thinking something along the lines of [Garage garage = new GarageC.getInstance("GarageC", numFloors, areaofEachFloor);] but i...

  • help me with the loops and the last part of this question .i am using c...

    help me with the loops and the last part of this question .i am using c language....speed=distance/time....in the 1st part of the program i had to write a program to calculate speed...we had to input distance in meters and time in seconds. 2. Strength. The robots will attempt to lift several heavy objects 3. Combat effectiveness. The robots will battle against 100 humans and then receive a score based on the number of victories. Create three functions (one for each...

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • I have updated my previously posted C++ question to ensure that I have included all of...

    I have updated my previously posted C++ question to ensure that I have included all of the necessary documentation in order to complete Part 2 - Bank Account of the assigned lab in its entirety. Please note that the lab below is somewhat lengthy, and I do not expect you to answer each question! If coding the full lab is too much to ask, please focus soley on Part 2 of the lab, titled Bank Account and the subsections that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT