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 questions

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







SPI questions
PostPosted: Sun Apr 02, 2006 1:10 am     Reply with quote

Hi,

I'm currently working on a sumo robot and intend to try to use SPI. Unfortunately I have never used SPI before and I find it very difficult to understand how I should program it. The PIC I'm programming is supposed to be used as a slave and only transmitt data to the DSP working as a master. I have several PIC's working as slaves in the system and each PIC has several sensors whos information should be forwarded to the SIP master.
If I set it up like this:
setup_spi(spi_slave | spi_h_to_l | spi_ss_disabled );
What does spi_h_to_l and spi_ss_disabled mean?
The write the data can I write one sensor at a time and it will be buffered?
For example:
//Measure sensor one
....
spi_write (sens_1);
//Measure sensor two
....
spi_write (sens_2);

If I do this, will the master read the value of all the sensors or just the last one? If it only reads the last one, how can I solve the problem?

I'm sorry if I'm asking a lot of stupid questoins, but I really hope someone can help me
Shocked

Thanks!
//Daniel Very Happy
Ttelmah
Guest







PostPosted: Sun Apr 02, 2006 2:22 pm     Reply with quote

This is fairly complex. Are you _sure_ you want to use SPI?. _I2C_, is a much simpler technology for having multiple slave devices. For more than one device, SPI, requires hardware addressing. This will require you to enable the 'ss' option on the slave, and have the select line for each slave, going to either a seperate line on the master PIC, or add logic to provide address decoding. If transfers are only going to take place in one direction at a time, then there is little advantage to using SPI.
'SS_DISABLED', turns off the select line, which otherwise allows the slave to be addressed. For multiple slaves, you are going to _need_ this.
The 'spi_l_to_h' declaration, controls which clock edge the port will sample the incoming data on.
Unless this data is going to be synchronous to events on the master chip, you need to remember that the 'slave', cannot institute transmission, and if servicing needs to be quick, have a hardware signal from the slaves to the master to force service.

Best Wishes
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