View previous topic :: View next topic |
Author |
Message |
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
spi_setup |
Posted: Tue Sep 25, 2007 9:16 pm |
|
|
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
|
|
|
Guest
|
|
Posted: Tue Sep 25, 2007 9:57 pm |
|
|
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
|
|
Posted: Tue Sep 25, 2007 10:13 pm |
|
|
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. |
|
|
|