EEPROM SPI Reading issue
Hello,
I am trying to write and read from stm32f105 to an eeprom 93AA46A, using Full-Duplex Master.
To write into the eeprom, I am using following code:
void EEPROM_WriteEnable(void)
{
uint8_t cmd = EEPROM_CMD_WRITE_ENABLE; //0x98
EEPROM_CS_HIGH();
HAL_Delay(1);
HAL_SPI_Transmit(&hspi1, &cmd, 1, HAL_MAX_DELAY);
EEPROM_CS_LOW();
}
void EEPROM_WriteByte(uint8_t address, uint8_t data)
{
uint8_t txData[3];
// Enable Write Operation
EEPROM_WriteEnable();
// Prepare Write Command (101xxxxx | 6-bit address)
txData[0] = EEPROM_CMD_WRITE; //0xA0
txData[1] = 0x00; //address
txData[2] = 0x55; // Data
// Send Write Command
EEPROM_CS_HIGH();
HAL_Delay(1);
HAL_SPI_Transmit(&hspi1, txData, 3, HAL_MAX_DELAY);
EEPROM_CS_LOW();
}
and to read from EEPROM, I have follwoing code:
void EEPROM_ReadByte(uint8_t address)
{
uint8_t txData_read[3];
uint8_t rxData = 0;
txData_read[0] = EEPROM_CMD_READ; //0xC0
txData_read[1] = 0x00; //address
txData_read[2] = 0x01; // dummy
EEPROM_CS_HIGH();
HAL_Delay(1);
HAL_SPI_Transmit(&hspi1, txData_read, 3, HAL_MAX_DELAY);
HAL_SPI_Receive(&hspi1, rxData, 1, HAL_MAX_DELAY);
EEPROM_CS_LOW();
}
I don't get anything from eeprom, the HAL_SPI_Receive doesn't make anything. Is there anyone that can verify that the code is correct?
Thank you.
