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

Help with SPI

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 02, 2009 5:41 pm     Reply with quote

Look at the SPI timing diagram on page 5 of the data sheet:
http://www.analog.com/static/imported-files/data_sheets/ADIS16209.pdf
The timing diagram shows that SCLK idles high and samples Din on the
rising edge. This is SPI mode 3. See the following web page:
http://www.totalphase.com/support/kb/10045/#modes

To implement this, add the following statements above main().
Code:
#define SPI_MODE_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1  (SPI_L_TO_H)
#define SPI_MODE_2  (SPI_H_TO_L)
#define SPI_MODE_3  (SPI_H_TO_L | SPI_XMIT_L_TO_H)

Then put SPI_MODE_3 in your setup_spi() statement.

The SCLK frequency may be limited to only 1 MHz maximum, depending
on the mode of the ADIS16209 chip. You did not post your PIC's clock
speed. Let's assume it's over 16 MHz. Then you need to use this divisor
in your setup_spi() statement:
Code:
SPI_CLK_DIV_64 



Also note from the ADSI16209 data sheet that there is a Startup Time
of 190 ms. Don't attempt to read data from the chip before that time
has passed. Put a delay_ms(200) statement at the start of main().
andreluizeng



Joined: 04 Apr 2006
Posts: 117
Location: Brasil

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

PostPosted: Mon Mar 02, 2009 5:44 pm     Reply with quote

I dont think so Guest.
_________________
Andre
Guest








PostPosted: Tue Mar 03, 2009 2:22 am     Reply with quote

Have you remembered the required 10K pull-ups on both SDA and SCL?
P.S. is that you Sam?
Gerry
Ttelmah
Guest







PostPosted: Tue Mar 03, 2009 3:11 am     Reply with quote

Anonymous wrote:
Have you remembered the required 10K pull-ups on both SDA and SCL?
P.S. is that you Sam?
Gerry

Not on _SPI_.
Pull ups are needed for I2C, which is a 'open collector' bi-directional bus, but SPI does not need these.

Best Wishes
libellej8



Joined: 03 Mar 2009
Posts: 2
Location: Dorset UK

View user's profile Send private message

PostPosted: Tue Mar 03, 2009 7:18 am     Reply with quote

Ttelmah wrote:
Anonymous wrote:
Have you remembered the required 10K pull-ups on both SDA and SCL?
P.S. is that you Sam?
Gerry

Not on _SPI_.
Pull ups are needed for I2C, which is a 'open collector' bi-directional bus, but SPI does not need these.

Best Wishes


Thanks Ttelmah,
I stand corrected.

Sam,
I have some code that I used for an AD rate gyro, ADIS16255 same family, that works. I can't publish it here as it is proprietary, but you have my e-mail address.
Gerry
andreluizeng



Joined: 04 Apr 2006
Posts: 117
Location: Brasil

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

PostPosted: Tue Mar 03, 2009 8:14 am     Reply with quote

Gerry, I would be glad if you send it to me too =)

thanks..

regards.
_________________
Andre
priesty100



Joined: 16 Oct 2007
Posts: 6
Location: UK

View user's profile Send private message MSN Messenger

PostPosted: Tue Mar 03, 2009 5:28 pm     Reply with quote

Thank you all for your help,

I hadn't realised about the CS being required to sync the devices. Not sure how I managed to miss that I was only reading in 8bits.

Hey Gerry, yeah, its me, see what happens when I'm removed from your watchful eye, I've been trying to get that to work all day!

Thank you all again.

Regards
_________________
Sam
mazen82



Joined: 10 Sep 2009
Posts: 22

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 7:08 am     Reply with quote

where you able to get it to work? can you post the code?
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