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

SPI comunication between 2 pic

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



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

SPI comunication between 2 pic
PostPosted: Thu Jan 04, 2007 11:29 am     Reply with quote

Hi to Everybody,

I'm thinking to use SPI for comunication between one PIC18 master, and PIC16, slave with lcd and keyboard. I already used RS232 in PIC18 for PC comunication. The distance between master and slave are 2 meters.
I want use only 3 wire so I don't want use SS pin to enable the slave.
By your experience does it possible ?

Thanks for any suggestion,
Regards,
ckielstra



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

View user's profile Send private message

PostPosted: Thu Jan 04, 2007 1:44 pm     Reply with quote

Quote:
The distance between master and slave are 2 meters.
I'm not sure about the maximum allowed length for a SPI connection, but with this length you are in the danger zone. To minimize problems use low clock frequencies, maybe something like 100kHz max.

Quote:
I want use only 3 wire so I don't want use SS pin to enable the slave.
By your experience does it possible ?
With only one device connected to the SPI bus this should be possible. Be carefull though that now the slave device will always be activated and listening for incomming clock pulses. If on power up, after reset, or by noise a spike is induced on the clock line your slave will get out of sync. You will need a software protocol that is capable of detecting these errors (CRC check) and correcting them (requires a start- and/or end-flag).

Why not use I2C? It has the following advantages:
- uses only two signal wires (plus ground)
- has better described physical specifications
- multiple slaves are possible without adding more (select) wires.
- the problem of loosing synchronisation by accidental clock pulses has already been taken care of.
- Maximum distance depends on speed and bus loading but 3 to 4 meters is easily achieved.

A disadvantage of I2C is that driving the bus is a bit more complicated but many PIC processors do have I2C decoding hardware present.
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Fri Jan 05, 2007 2:10 am     Reply with quote

Hi ckielstra,

Really I have 3 open hardware possibility, SPI, I2C and software RS232. The software RS232 is the easy way. I've 4 phase speed controll working under timer0 interrupt and every 100us I need to service that routine. So I decided to have comunication based on hardware interrupt, just to service it for required time, no more.

Master PIC is 3V power supply otherwise Slave PIC is 5V power supply.
With SPI I tought to use 2 level translator and have the comunication signal, on connected cable, of 12V.

What is the maximum lenght of I2C bus ?
Can I connect directly PIC18 (3V supply) and PIC16 (5V supply) with I2C bus ?

Thanks for reply
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