Hi könntest du bitte mal deinen Code Posten ?
Ich hab nämlich den 95256 und ist ja lt Datasheet fast das gleiche Teil,
nur doppelt so groß wie deiner. Aber ich hab da Probleme ich lese immer
0xff zurück. Wobei ich ja noch nicht mal richtig weiss ob ich richtig
schreib !
Also ich hab im SPI CPOL = 0 und CPHA auch. Stimmt dass vom Spi schon
mal ?
und hier der Code.
unsigned int extern_ee_write_byte(unsigned char data, unsigned int
adress)
{
unsigned char data_ret = 0;
unsigned int timeout = 0;
sbi(SPCR,CPOL);
//Check if Device is busy, if busy -> wait until ready
cbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS LOW
//Wait for Bit is cleared
while ( data_ret & (1<<WIP) && (timeout < 32000) )
{
data_ret = SPI_MasterTransmit(RDSR);
timeout ++;
}
timeout = 0 ;
was ist nun noch falsch ich verstehs ned ?
hier noch die commando codes:
#define WREN 0x06
#define WRDI 0x04
#define RDSR 0x05
#define WRSR 0x01
#define READ 0x03
#define WRITE 0x02
#define SRWD 7
#define BP1 3
#define BP0 2
#define WEL 1
#define WIP 0
sbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS HIGH
// Device Ready not Busy
// Set Write Enable Latch
cbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS LOW
data_ret = SPI_MasterTransmit(WREN);
sbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS HIGH
// Wait for Bit is set
cbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS LOW
while ( data_ret & (1<<WEL) && (timeout < 32000))
{
data_ret = SPI_MasterTransmit(RDSR);
timeout ++;
}
sbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS HIGH
// Device Ready to write
cbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS LOW
SPI_MasterTransmit(WRITE); // Set Write Modi
SPI_MasterTransmit( (unsigned char) ((adress>>8)&& 0xFF) ); // Adress
High Byte
SPI_MasterTransmit( (unsigned char) (adress && 0xFF) ); // Adress
Low Byte
SPI_MasterTransmit(data); // DATA zu write
sbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS HIGH
cbi(SPCR,CPOL);
}
und lesen :
unsigned int extern_ee_read_byte (unsigned char data, unsigned int
adress)
{
unsigned char data_ret = 0;
unsigned int timeout = 0;
sbi(SPCR,CPOL);
cbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS LOW
//Check if Device is busy, if busy -> wait until ready
while ( data_ret & (1<<WIP) && (timeout < 32000))
{
data_ret = SPI_MasterTransmit(RDSR);
timeout ++;
}
sbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS HIGH
// Byte schreiben
cbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS LOW
data_ret = SPI_MasterTransmit(READ); // Set Read Modi
data_ret = SPI_MasterTransmit( (unsigned char) ((adress>>8)&& 0xFF) );
data_ret = SPI_MasterTransmit( (unsigned char) (adress && 0xFF)
);
sbi(PORT_CS_EEPROM,PIN_CS_EEPROM); //CS HIGH
cbi(SPCR,CPOL);
return data_ret;
}