UART Configuration of PIC16F877A

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

UART Configuration of PIC16F877A

Postby Ryu » Wed Nov 23, 2011 10:21 pm

Hi everyone, i need some information about UART configuration for Pic16f877A. I went through the sample code provided by Cytron and i think i need to modify it to suit my program. As i observe, UART TX is connected to RC6 and RX is connected to RC7. Do i need to #define RC6 and RC7 to Input in d beginning ? or Anyone can help to provide some information of configuration.
Thank in advance.

CODE: SELECT_ALL_CODE
//Configure UART
   SPBRG=129;         //set baud rate as 9600 baud
   BRGH=1;            //baud rate high speed option
   TXEN=1;            //enable transmission
   TX9 =0;            //8-bit transmission
   RX9 =0;            //8-bit reception   
   CREN=1;            //enable reception
   SPEN=1;            //enable serial port
Ryu
Newbie
 
Posts: 13
Joined: Sun Aug 14, 2011 10:32 pm

Re: UART Configuration of PIC16F877A

Postby yonghui » Thu Nov 24, 2011 1:01 am

hi,

i think in datasheet there will be a section in the uart part mentioning the steps involve to setup the uart. u can refer to that for different kind of uart configuration.

tx pin is output and rx pin is input. i think is automatically set when uart is enable.



regards,
yh
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: UART Configuration of PIC16F877A

Postby ober » Thu Nov 24, 2011 10:49 am

Is a good practice to configure the Tx as output and Rx as input at initial, but not using #define, the TRISC control input and output. Yes, as yonghui say, it might also being auto configure when UART is being setup.

Basically, the sample code you paste is the configuration for UART.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 2 guests

cron