CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

software UART and hardware UART, please explain...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
runtime



Joined: 15 Sep 2003
Posts: 36

View user's profile Send private message

software UART and hardware UART, please explain...
PostPosted: Thu Jul 22, 2004 11:31 am     Reply with quote

Hello all,

This must be a silly question, but please explain to me the difference between a software UART and hardware UART, which is best? how do I implement a hardware UART? (PIC16F876)

Thank you in advance
Peter
yeti
Guest







uart
PostPosted: Thu Jul 22, 2004 12:00 pm     Reply with quote

Hey,

A Hardware USART has dedicated circuitry etched into the micro's silicon. Therefor it takes almost zero code space and is always there regaurdless if you use it or not.

A Software USART uses code to transition output pins and read input pins in order to communicate. This takes up a fair amount of program space for the protocal, buffer, etc. expecialy if you are using advanded serial communications. But it is also the most flexible.

I use the hardware USART when ever possible - it's "free". I have not looked at the Pic you mentioned, so I don't even know if it has a hardware USART.

Have Fun
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Jul 22, 2004 12:18 pm     Reply with quote

Software UARTs are more flexable. The CCS software UART can even invert the data if you want. If you write your own it can do anything. Howeve most software UARTs, like the CCS one, consume all the CPU time while they are operating. This means while you are transmitting or receiving a character the CPU can do nothing else.
However the CCS recieve routing actually finishes at the middle of the Stop bit. That means you can recieve a command byte at a time and interpret each byte in the latter half of its Stop bit. This is very useful if you don't have RAM to spare buffering a whole serial message.
_________________
The search for better is endless. Instead simply find very good and get the job done.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Jul 22, 2004 12:27 pm     Reply with quote

Whenever possible use a hardware UART! It has the following advantages:
- Your code can do other things while 'in the background' the hardware is receiving data. Communicating at 9600 baud a single character takes 1ms, imagine how much code you can execute in this time.
- A hardware UART is more stable because it's timing is not affected by interrupts (A SW UART must disable the interrupts).
- It can buffer 3 incomming characters and 1 outgoing character.
- Much higher baudrates are possible.
- Automatic checking of the parity bit is possible.
- Framing and overrun errors are detected.

The only reasons for using a software based solution are:
- You need more serial ports than there are HW UARTS on your chip.
- Your communication uses 5, 6 or 7 databits.
- You want to save a few cents by not including an inverter chip like the MAX-232 but instead use a resitor/diode network. The software UART allows you to use the INVERT option for this.

For example code see the manual or search this forum for '#use RS232'.
Guest








PostPosted: Sun Jul 25, 2004 9:57 am     Reply with quote

Hi, i am learning to program pics, and after read this topic, i want to see a sample, please.

a sample of hardware and software, please someone can post it?

for 16f627 or 16f628 or 12c509 or 16f876 or 16f870

thanks
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Jul 25, 2004 12:21 pm     Reply with quote

Like I said before: Look in your manual for the instruction '#use RS232' or uses the search function of this forum with the same keywords.

This question has been asked so many times that you will find many good answers anfd other helpfull information.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group