Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Info about using USART in PIC 16f877A

Status
Not open for further replies.

vishy71

Full Member level 2
Full Member level 2
Joined
Dec 16, 2010
Messages
126
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Iran
www.korosh-life.blogfa.com
Activity points
2,296
hi there
I wanna get information about USART in pic!I have some example codes but I
wanna know register bit's configuration and what can it do!

thanks
 

Re: USART in PIC 16f877A

Hi vishy71,

Using USART, first try to send out some characters to PC with pickit2-UART tool. Then try the receiving. While doing this you will completely familiarize with PIC UART. Follow datasheet for detailed operation of USART.

Use null-modem configuration for wiring uC serial-port and pickit2-UART;

1. Select the ASYNCHRONOUS mode for transmitting data (SYNC bit);
2. Select baud-rate which has lowest error % with your uC oscillator speed (BRGH bit and SPBRG register);
3. Enable serial-port (SPEN bit);
4. Select 8bit data mode (TX9 bit);
(Load data to be transmitted to TXREG)
5. Enable transmitter(TXEN bit);
6. Check TXIF bit to load next data to be transmitted for TXREG;


If you don't have pickit2, you may connect to PC com port via max232 IC. (building pickit2 is better !)

Hope this give you some info to start,
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating
Re: USART in PIC 16f877A

Hi,

You are progressing ...:-D


See this good tutorial for general RS232 / Usart details and example 7.7 which uses the hardware Usart of the 876A/877A chips.
PIC Tutorial* Seven - RS232

If you have a Pickit2 you can use its USART progam to test your code.
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating
Re: USART in PIC 16f877A

Hi wp100
i have seen this page in other thread that you introduce it to somebody!
yes I am progressing
I tried ADC,PWM,TMR,LCD,Interrupts and...
but I have too many problems to be a profesional as you!
In this page for 9600bit/s are you sure we must wait 104us?
may it be false?or make wrongs?
I mean is this time exactly?
thanks

---------- Post added at 20:15 ---------- Previous post was at 20:14 ----------

I am progressing with your helps! thanks wp100!I don't know how can I answer your helps!

---------- Post added at 20:29 ---------- Previous post was at 20:15 ----------

wp100! here is the program that I have made it today!it's for LCD!
you know it's difficult and takes too many times to find your character and get it's ASC and use in MPLAB!
so! I made this programe with VB6! you must write your text in Text box and write label name in your code!
label name is instruction of send character to LCD!like LCD_CHR!
click on About!there is special thanks for you!
thanks
Download
 

Re: USART in PIC 16f877A

Hi,

The 104us is the time taken for 1 Bit to be sent out at 9600 Baud - you can use faster rates but you must consider the device you are communicating with - some devices are limited in their transimission speed.

Most of Nigels tutorial examples are for Software Usarts so yes you must wait 104us for each bit to be sent out.

With your chip you have an onboard Hardware Usart, you program up the required Baud rate and then just pass your Byte of data to the Usart, it will deal with all the sending and receiving of the data.
You can then carry on with you main code, the Usart will set its flags when the data has been sent and ready for the next byte.
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating
Re: USART in PIC 16f877A

Hi,

Thanks for the program link, but was only able to run your program once, strange things were happening and the system nearly crashed.

Did just get chance to see what the program did but it makes me wonder why you are having to use that ?

You can enter Ascii data directly into your program code - movlw 'H'

If you are using masses of pre written message text then there are other ways of sending data ot to the LCD.
This allows the messages to be stored as 'strings' of data - 'Hello World'
Its not a method I have used on my lcd but there are examples around.

When you have data read in from sensors etc that needs converting to ascii by the ascii converter - that should be easily done by using the Call instruction.

I know its difficult with me only speaking English , so perhaps post your code so we can see how you are doing, you can always send it in a PM
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating
Re: USART in PIC 16f877A

You need to read **broken link removed**! I recently completed a project and i read this book to help me initialize the connection both on computer and pic side. You should also read the datasheet. Just those two is everything you need, is really easy!
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating
oh! wp100 thanks! but I don't know we can write movlw 'H'!!!!!!!!!!!!!!!!!
sorry I forget make this programe as Instalition!because the programes wich have writen by VB6 need it's files!
you must write
movlw 'A'
call ....
movlw 'm'
call ...
movlw.....
.....
but in this program you can write your message and then take codes!
I am starter and I don't know how can I use string of data!
thanks!
 

Hi

The Stopwatch -
 

Attachments

  • ScreenShot002.jpg
    ScreenShot002.jpg
    91.9 KB · Views: 193
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top