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

SPI Newbie connection check

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



Joined: 21 Oct 2003
Posts: 58

View user's profile Send private message

SPI Newbie connection check
PostPosted: Thu Aug 02, 2007 3:30 am     Reply with quote

Hi All

Attempting my first use of SPI was wondering if someone could check if I have connected things up ok as the pcb has to go off to be made before I get to check things fully out due to time restrictions.

I'm connecting to a Microchip MCP41100 digital potentiometer to a 16F690.

My connections are :-
Pin 9 of the PIC(SDO) to pin 3(SI) of the digipot
Pin 13of the PIC(SDI) to pin 1(CS) of the digipot
Pin 11 of the PIC(SCK) to pin 2(SCK) of the digipot

TIA

JFK
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 02, 2007 3:54 am     Reply with quote

Have you checked out page 7 of the Digital Potentiometer Design Guide?
Here several possible configurations are described for the SPI setup. None of these has SDI of the PIC connected to the CS of the digipot...
jfk1965



Joined: 21 Oct 2003
Posts: 58

View user's profile Send private message

PostPosted: Thu Aug 02, 2007 5:16 am     Reply with quote

Thats correct it doesn't but the digipot data sheet doesn't have a pin labelled SDO and the only other available is labelled CS and it's function is described as the SPI port chip select pin and is used to execute
a new command after it has been loaded into the
shift register.

JFK
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 02, 2007 6:22 am     Reply with quote

The 8 pin digipot doesn't have an SPI output pin, the 14 pin version does (named SO).

Connecting the PIC's SDI pin to the digipot's CS is not going to work while SDI and CS have completely different functions (both are inputs !).
CS is short for Chip Select and is used on the SPI bus to make it possible for multiple chips to select the same data and clock lines. Just before you are going to send data to any chip on the bus you activate the CS line for that particular chip. When finished communicating you disable the CS line again.
The SDI pin is used for reading data in from the external device. You already figured out that the digitpot doesn't have a corresponding SDO so this means SDI on the PIC is not going to be used.
Note: Never create a design with open input ports as oscillation might cause high current consumption. Connect the SDI input to Vcc or Vdd (with pull-up or pull-down resistor).

Because SDI on the PIC is not going to be used as a SPI input you might have considered to configure this pin as a digital output. This isn't going to work as the PIC hardware overrules any manual TRIS setting for this pin and makes it an input (see chapter 13.3 of the PIC datasheet).
jfk1965



Joined: 21 Oct 2003
Posts: 58

View user's profile Send private message

PostPosted: Thu Aug 02, 2007 7:03 am     Reply with quote

Thanks thats clearer do I assume that the CS isn't a dedicated pin on the pic as there doesn't appear to be one in the pic datasheet and can be assigned to any spare I/O pin (except the SDI pin)?

thanks again ckielstra your time and partience is appreciated.

JFK
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 02, 2007 7:29 am     Reply with quote

Quote:
Thanks thats clearer do I assume that the CS isn't a dedicated pin on the pic as there doesn't appear to be one in the pic datasheet and can be assigned to any spare I/O pin (except the SDI pin)?
Yes, you can take almost any pin you want. Make sure to check the section on I/O ports in the datasheet as some ports have limitations, for example RA3 can only be used as input.

Last edited by ckielstra on Thu Aug 02, 2007 7:36 am; edited 2 times in total
jfk1965



Joined: 21 Oct 2003
Posts: 58

View user's profile Send private message

PostPosted: Thu Aug 02, 2007 7:36 am     Reply with quote

I'm 100% clear now in what I'm doing.

Thanks again

JFK
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 02, 2007 7:37 am     Reply with quote

A design hint: If you are only using SPI for controlling the digipot you might consider implementing the SPI driver in software instead of in hardware (easy to do). This way you don't use the inbuilt SPI hardware and then the SDI pin is free for other uses.
jfk1965



Joined: 21 Oct 2003
Posts: 58

View user's profile Send private message

PostPosted: Thu Aug 02, 2007 8:22 am     Reply with quote

Thanks for the suggestion i'll consider it in the future, but for this application I have sufficient pins available.

JFK
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