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 CCS Technical Support

UART software versus hardware and Interrupts?

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



Joined: 11 Jan 2010
Posts: 8

View user's profile Send private message

UART software versus hardware and Interrupts?
PostPosted: Mon Oct 04, 2010 4:36 am     Reply with quote

Hi

I have two simple questions:
(a) Can a software UART transmit at 57.6kBaud using a 12MHz Xstal? and What is the fastest that the software UART can transmit with a 12MHz Xstal?
(b) If I have various interrupts, what will occur with the UART transmission?

Thank you in advance.
a.
niktab



Joined: 20 Jul 2010
Posts: 2

View user's profile Send private message

PostPosted: Mon Oct 04, 2010 5:01 am     Reply with quote

i strongly recommend, do not use software uart simulation, especially if you use any interrupts. this probably will cause real mess. Smile
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Oct 04, 2010 5:28 am     Reply with quote

If you search the forum, you will find that some time ago, the 'instructions per bit' for the software UART was posted. I think 57600, is 'pushing it'. My memory was somewhere around 60 instructions 'worst case'. At 57600, on a processor at 3MIPS, you have 52 instructions per bit.
On interrupts, you _cannot_ have interrupts enabled while transmitting, especially at a rate like this (it takes more time than a single bit, to get into, and out of an interrupt handler, even 'doing nothing' in the handler). You can though use the 'DISABLE_INTS' option in the use RS232 declaration, so that they are disabled on a 'per character' basis, which will allow your interrupts to occur 'between' the characters (if you have an older compiler, you can instead encapsulate the transmission to do this).

Best Wishes
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Oct 04, 2010 8:26 am     Reply with quote

I agree. Software UARTs in a pinch only.

Hardware UARTs are good.

Interrupts are fabulous.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
SherpaDoug



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

View user's profile Send private message

PostPosted: Mon Oct 04, 2010 8:48 am     Reply with quote

Software UARTs are perfectly legitimate. They do take a lot of CPU time and a little ROM space. But for a project that has a specific "setup" or "download" phase when the CPU would be idle anyway, software UARTs allow you to use PICs that don't have hardware UARTs, or not enough UARTs.

Also software UARTs are sometimes a lifesaver for debug.
_________________
The search for better is endless. Instead simply find very good and get the job done.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Oct 04, 2010 8:56 am     Reply with quote

I still only use them in a pinch.

So many PIC's come with HW UART's now...

what the decision making process comes down to this:

Will the PIC be busy enough where you can't afford to miss RS232 data and you can't afford to stop doing other things.

If the answer is yes, then hardware UARTs.

If the answer is no, then software is ok.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Oct 04, 2010 9:02 am     Reply with quote

Remember though that the original poster, was asking about transmit, not receive. So the comments about 'missing data', don't apply. Software UART's, used with care are fine for transmit. For receive, they are much more of a problem. Though 90% of PICs 'come with a UART'. if you have multiple serial streams involved, a software UART may be useful.

Best Wishes
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Oct 04, 2010 9:05 am     Reply with quote

Ttelmah wrote:
Remember though that the original poster, was asking about transmit, not receive. So the comments about 'missing data', don't apply. Software UART's, used with care are fine for transmit. For receive, they are much more of a problem. Though 90% of PICs 'come with a UART'. if you have multiple serial streams involved, a software UART may be useful.


I know, I just just describing how I usually decide the soft/hard UART question.

If TX is all he's doing.. then software might be fine. 'specially in a loop controlled environment. (no IRQ's.. just a main that does item 1, then 2, then 3 then repeat.)

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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