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

#use spi

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



Joined: 15 Oct 2011
Posts: 7
Location: CHENNAI

View user's profile Send private message Send e-mail

#use spi
PostPosted: Fri Nov 25, 2011 12:05 am     Reply with quote

I am using pic18f4431 for my application.
In that ic I have 2 spi pins.
One is RD1-SDO, RD2-SDI, RD3-SCK.
Another is RC7-DO, RC4-SDI, RC5-SCK.
I want to use #use spi command. In that command
FORCE_HW one command is there........
What my is doubt, is how can I specify the RD1, RD2, RD3 for spi ?
Anyone clear my doubt.
_________________
EDWARD
Ttelmah



Joined: 11 Mar 2010
Posts: 19348

View user's profile Send private message

PostPosted: Fri Nov 25, 2011 3:02 am     Reply with quote

Two different processes, for different chips.

A lot of later chips, have pins 're-mappable' in software. On these you use #PIN SELECT. However on yours, if you check the data sheet, the re-mapping is controlled by a fuse. If you look at the fuse list for your chip, you have:
3.10 SSP_RD SCK/SCL=RD3, SDA/SDI=RD2, SDO=RD1
3.10 SSP_RC SCK/SCL=RC5, SDA/SDI=RC4, SDO=RC7

So all you do, is select the fuse you require SSP_RD to put the SSP on port D, or SSP_RC to put it on port C.

So just add SSP_RD to your fuses, and in the #use SPI, use 'SPI1', which will automatically select the hardware pins.

You may (according to the age of your compiler), find it does not correctly set the TRIS bits when you use the alternate pins (this varies from chip to chip, and compiler version to version....). If it doesn't work, manually set the TRIS bits as shown in the data sheet.

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