According to what I have seen about SPI, I think the following code should work fine (Writing a 0x0E and later reading it:
But instead, rxdata is all the time 0x00 (which, in fact, if the write never occurs, it's what should be as it's an EEPROM full of 0's), the write really seems not to happen as if I read the EEPROM there doesn't seem to be 0x0E anywhere.
I know it's not too useful to write on an EEPROM memory position (which I think this code should be doing), but right now, I just want to check SPI functionallity before getting into more difficult things.
Maybe as it's an EEPROM it requires some type of special treatment other SPI devices don't need, but as from what I read seems not to, I'm posting this here.
Thanks.
Code:
#include "p18F4620.h"
#include "spi.h"
#pragma config XINST=OFF
#pragma config OSC=INTIO67
#pragma code
void main (void)
{
char rxdata;
//SS' is on RA0
TRISA = 0b00000001;
TRISC = 0b00010000;
TRISE = 0b00000000;
SSPCON1bits.SSPEN = 1;
SSPCON1bits.CKP = 0;
SSPSTATbits.SMP = 1; /* Data Input Sample Bit: Cleared in SPI slave mode */
SSPSTATbits.CKE = 0; /* Clock Edge Select Bit: (1)transmit occurs on transition active->idle */
SSPCON1bits.SSPM3=0;
SSPCON1bits.SSPM2=0;
SSPCON1bits.SSPM1=0;
SSPCON1bits.SSPM0=0;
WriteSPI("0x0E");
while (!SSPSTATbits.BF);
rxdata=ReadSPI();
}
But instead, rxdata is all the time 0x00 (which, in fact, if the write never occurs, it's what should be as it's an EEPROM full of 0's), the write really seems not to happen as if I read the EEPROM there doesn't seem to be 0x0E anywhere.
I know it's not too useful to write on an EEPROM memory position (which I think this code should be doing), but right now, I just want to check SPI functionallity before getting into more difficult things.
Maybe as it's an EEPROM it requires some type of special treatment other SPI devices don't need, but as from what I read seems not to, I'm posting this here.
Thanks.