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

spi_setup

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



Joined: 01 Aug 2007
Posts: 38
Location: AUckland, NEW ZEALAND

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

spi_setup
PostPosted: Tue Sep 25, 2007 9:16 pm     Reply with quote

Hi, just need some verification that the following setup

setup_spi(SPI_MASTER | SPI_XMIT_L_TO_H | SPI_H_TO_L | SPI_CLK_DIV_16);

I have a PIC18F452 and need to communicate to a m25p40 (spi-eeprom)

The eprom reads on the rising edge and transmits on the falling edge.

Is the above setup for the PIC correct, because i havent been able to communicate with it so far? Has anyone had experience with this eprom?

Ive tried to debug it using LEDS and havent been able to read the values from the epromm correctly.
Any help appreciated, Cheers
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 25, 2007 9:38 pm     Reply with quote

Read my post in this thread, which explains how to determine the
correct setup for the SPI mode and SPI clock frequency.
http://www.ccsinfo.com/forum/viewtopic.php?t=31594

Also make sure you have correctly connected the SPI pins on the PIC to
the SPI pins on the other device. See my post in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=32118
Guest








PostPosted: Tue Sep 25, 2007 9:57 pm     Reply with quote

Thanx for quick reply

Quote:
Read my post in this thread, which explains how to determine the
correct setup for the SPI mode and SPI clock frequency.


So does this mean every time i want to change from reading the eprom to sending to the eprom i have to change the spi_setup every time. (as reading is different transition to transmitting).

I have checked the pin configurations many times over, so confident they are correct, just the communication i beleive is my problem

Cheers
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 25, 2007 10:13 pm     Reply with quote

You don't have to do that. I don't think any SPI device operates that
way. Just pick one of the two modes, and set it up for that.
I recommend using Mode 0. Look in the thread that I mentioned, and
add the #define statements for the SPI modes to your program. Then
use the constant for Mode 0, and put it in your setup_spi() statement, as
shown in the sample code in that post.
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