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

comparing the two SPI methods for 16Fxxx

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



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

View user's profile Send private message AIM Address

comparing the two SPI methods for 16Fxxx
PostPosted: Sun Apr 12, 2009 12:48 pm     Reply with quote

before starting a project that requires 4 different SPI devices - and 3 different operating modes, that are dynamically switched ( via Not-CS)
on the 16f887 ( with hardware SPI)
sharing the std C port hardware pins for CLK DI DO for all SPI clients
---------
which of the two setup methods is believed more robust for on-the-fly
mode changing operation ??

#USE SPI ....

or

setup_spi() and its intrinsic function allies

are both needed

??

so far i've used #USE SPI with parameters in the header zone of the test program - followed by setup_spi () in the INIT zone
with no problem - with just ONE of the SPI devices-
but no mode changes added to the code so far - with 100% success
on the latest 4.x version of the compiler

Thanks in advance for any informed comments that would illuminate this
better
Ttelmah
Guest







PostPosted: Sun Apr 12, 2009 3:15 pm     Reply with quote

Realistically, I'd use setup_spi.
No, only one is needed. The setup_spi function, is the 'older' route, and is really the better suited for what you are doing, since it puts the timing of the reprogramming of the peripheral completely at your command. With the #use syntax, the code ought to reprogram the peripheral as needed (using multiple streams), but I'd prefer to simply ensure that all the chips are deselected, send the correct setup_spi, which reprograms the chip 'then and there', then enable whichever chip is required, and talk to it. The setup_spi command, actually sends the selected configuration bytes to the peripheral when it is called, and hopefully allows the changes to take place when you expect them, not at some other 'compiler decided' point.....
#use SPI, is the 'required' route, if using software SPI, or if wanting to perform functions not supported by the hardware, adding the extra code to provide these. Setup_spi is the 'simpler' route to use the hardware.

Best Wishes
asmboy



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

View user's profile Send private message AIM Address

PostPosted: Sun Apr 12, 2009 6:06 pm     Reply with quote

I knew somebody would have a fix on the right answer.

What you said makes perfect sense - .


THANK YOU Mr. 'T' for your scholarly 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