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 CCS Technical Support

setup_spi() help

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



Joined: 06 Feb 2011
Posts: 8
Location: Pakistan

View user's profile Send private message AIM Address

setup_spi() help
PostPosted: Wed Feb 09, 2011 4:32 am     Reply with quote

In SPI two parameters are needed to be specified i.e. clock phase and polarity. IN CCS C's function setup_spi() only one parameter is there to set i.e. SPI_L_TO_H or SPI_H_TO_L . I want to know is this setting for polarity or phase and how to set the second parameter.
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Wed Feb 09, 2011 6:22 am     Reply with quote

First, read the chip's data sheet.

Note that the four options are controlled by the four possibilities from two bits CKE, and CKP.

Then read the manual.
Then look at the the actual constants available in the processor's include file. Note that there are more than in the manual.

SPI_XMIT_L_TO_H => Sets the CKE bit - Data is transmitted on the low to high, when the clock idles high. On high to low, when the clock idles low.
SPI_X_TO_X, sets the CKP bit. L_TO_H - clock idles low. H_TO_L clock idles high.
So all four options are here.

Then save yourself a lot of grief, (much better.....). Use the standard defines published here, that give the pairs of these 'Mode' numbers corresponding to the pretty standard SPI modes. Smile

Best Wishes
waqas_shafique



Joined: 06 Feb 2011
Posts: 8
Location: Pakistan

View user's profile Send private message AIM Address

PostPosted: Wed Feb 09, 2011 7:02 am     Reply with quote

good explanation thanks....

one more question,what if i want clock idle low and data transmit on low to high??? as there is no SPI_XMIT_H_TO_L
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Wed Feb 09, 2011 9:46 am     Reply with quote

H_TO_L, is the opposite of L_TO_H. It is what you get, if you _don't_ select the L_TO_H option.
As I said though pull the SPI mode defines off here. Much safer and easier than using the defines on their own.

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