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

Sleep on pic24 with RTCC not working
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 6066
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Oct 31, 2017 8:23 am     Reply with quote

When you decide on an external xtal, if you get a 'binary' one you'll have ZERO problems with UART speeds.
A 'binary' xtal is one that is a factor of 2. IE 2.457600 when divided down will give precise 9600 UART speed. Some datasheets have charts or tables showing this. PC UART clocks were/are 14.something MHz, again to give precise timings.

The 'problem' with say a 16.000000 MHz xtal is that the UART speed will be slightly off. If it's say -2% off and the other unit is +2% off, that's a 4% difference and the UARTs probably won't talk nicely to each other. Add in the PIC is cold (outside...data logging) and PC in warm office and the difference can be greater, so you lose communications.


jay
JMarysse



Joined: 27 Oct 2017
Posts: 9

View user's profile Send private message

PostPosted: Wed Nov 01, 2017 4:34 am     Reply with quote

Hi temtronic,

Thanks for this, we will keep this in mind when we start the redesign.
Ttelmah



Joined: 11 Mar 2010
Posts: 13049

View user's profile Send private message

PostPosted: Wed Nov 01, 2017 7:43 am     Reply with quote

Yes. This is why I suggested 7.3728MHz, as being one near to 8MHz, that does this. Exactly 64*115200.
newguy



Joined: 24 Jun 2004
Posts: 1480
Location: Edmonton, Alberta

View user's profile Send private message

PostPosted: Wed Nov 01, 2017 8:01 am     Reply with quote

Have to play devil's advocate. If you structure your code to require "integer ticks", then an integer crystal makes that easy. If you require CAN, then an integer crystal is pretty much the only thing that will work.

Serial is one of those things where a little frequency error, in my mind, is okay.
Ttelmah



Joined: 11 Mar 2010
Posts: 13049

View user's profile Send private message

PostPosted: Wed Nov 01, 2017 9:04 am     Reply with quote

The need for a binary UART crystal, rises the lower the frequency you want to run.

If you clock your CPU at 32MHz, the basic division error is only 0.6%. But clock at 4Mhz, and this shoots up to 3.6%....
In fact pure 'binary' crystals (not binary UART crystals) can be the best values for 'integer ticks'. Remember the internal timers themselves count in binary, so for a 1mSec 'tick', a 4.096MHz crystal is one of the easiest choices.
Obviously 'special needs' will have their own clocks required. USB & CAN for example.
It's a place where a bit of thought can improve the design for very little cost.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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