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

Sanity check SPI pins

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



Joined: 30 Oct 2003
Posts: 209
Location: Norfolk, England

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

Sanity check SPI pins
PostPosted: Wed May 12, 2010 8:19 am     Reply with quote

Hi, the following:

#use spi(DO=PIN_C5,CLK=PIN_C3,BITS=16,ENABLE=PIN_B4,FORCE_HW)

gives an "Wrong pins for H/W" error in compiler version 4.107
The device is a 18F2520
Datasheet says
RC5/SDO
RC3/SCK/SCL

can someone please show me the error of my ways!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 12, 2010 11:11 am     Reply with quote

To use the hardware module, it wants you to specify all the pins.
Add the declaration for the 'DI' pin, and it will compile. An easier
way to do it is, instead of specifying all the hardware pins, just
put in 'SPI1'. Then it knows to use the first hardware SPI module.
Will Reeve



Joined: 30 Oct 2003
Posts: 209
Location: Norfolk, England

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Wed May 12, 2010 11:31 am     Reply with quote

Interesting. I actually want to use the DI pin as an output. Don't need an input for my SPI application.
Does the hardware SPI force you to TRIS your DI pin as an input?

Datasheet states SDI is "automatically controlled by the SPI module"...so I assume hardware SPI is out for me! However it also states "Any serial port function that is not desired may be overridden by programming the corresponding data direction (TRIS) register to the opposite value.

n.b. I actually ended up bit-bashing in software to get me up and running but this will be for future reference!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 12, 2010 2:10 pm     Reply with quote

Quote:

However it also states "Any serial port function that is not desired may be
overridden by programming the corresponding data direction (TRIS)
register to the opposite value.

Set it up for SPI1, then do a test. Use output_low() and output_high() on
the SDI pin. See if it all works (both the SPI module and the i/o pin).
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