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

Different Clock Speeds with 2pics and SPI

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



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

Different Clock Speeds with 2pics and SPI
PostPosted: Tue Jun 04, 2013 9:41 am     Reply with quote

Hi There,

Will I have any problems in using SPI between two different pics - each with a seperate oscillator at different speeds?

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19365

View user's profile Send private message

PostPosted: Tue Jun 04, 2013 11:14 am     Reply with quote

Basically, no.

SPI is synchronous, so the master controls the timing.

However the slave actually has to do more work (generally going into an IRQ), so it may well be necessary to pause after sending bytes from the master, especially if this is the faster chip.

Best Wishes
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jun 04, 2013 11:26 am     Reply with quote

If you want maximum efficiency for hardware unidirectional SPI transfers
AND you can spare an extra IO pin on each pic -
semaphore your receipt of each 8 bits by toggling a pin output state when the transfer is complete.

The sender simply records the INPUT state of its semaphore receive pin
before executing the write_spi() and then loops while looking for the pin to change state.

The receiving pic, upon receipt of the most recent byte,doing any essential processing that the byte might require - next toggles the output semaphore pin that It controls. This will assure that even with very
mismatched PIC clock rates - and possible extra receiver overhead-
that you are safe to send.

Monitoring the send spi buffer alone won't assure safe receipt.
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Tue Jun 04, 2013 1:06 pm     Reply with quote

Superb answers as usual,

Thank-you both.

Carl
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