2020-06-22 12:09 PM
Hi,
Im using M95512-D EEPROM with STM32F103RCT7. EEPROM is connected with SPI2.
My Initialization and Read Write Process are given below, Please help me to make it work,
-----------------------------------------------------------------------------------------------------------------
/* SPI2 parameter configuration*/
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_MASTER;
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_SOFT;
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 10;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
/* User Code*/
uint8_t sEEstatus[1] = { 0x00 };
uint8_t command[1] = { EEPROM_RDSR };// EEPROM_RDSR =0x05
// Send "Read Status Register" instruction
if (HAL_SPI_Transmit(&hspi2, (uint8_t*)command,1, 200) != HAL_OK) {
Error_Handler();
}
// Loop as long as the memory is busy with a write cycle
do {
while (HAL_SPI_Receive(&hspi2, (uint8_t*)sEEstatus, 1, 200) == HAL_BUSY) {
HAL_Delay(1);
};
HAL_Delay(1);
} while ((sEEstatus[0] & EEPROM_WIP_FLAG) == SET);
// Write in progress
------------------------------------------------------------------------------------------------------
Status is always 0xFF i.e. not reading the data from eeprom
Please correct me if my code is wrong.
schematic for reference:
thanks,
pratheep
Solved! Go to Solution.
2020-07-03 12:37 AM
Hi,
/CS=1 means eeprom deselected.
To select the eeprom, you must pass /CS=1 to /CS=0 before starting communication. The transition high to low is mandatory.
If you always keep /CS=0 , you can't have communication master vs eeprom.
2020-06-22 12:26 PM
Chip select managed where?
2020-06-24 07:11 AM
Chip Select is Connected to Ground.
2020-07-01 05:04 AM
Hello
/CS must be with pull-up & managed by the µc.
If always connected to GND, the device can be selected. That's why you read always 0xFF.
See datasheet section 3.4 here : https://www.st.com/resource/en/datasheet/m95512-w.pdf
BR
Team EEPROM suPPort
2020-07-02 07:42 PM
Hi, I'm using only one slave on spi channel . So, is that wrong to keep pull down by default?
Thanks,
Pratheep
2020-07-03 12:37 AM
Hi,
/CS=1 means eeprom deselected.
To select the eeprom, you must pass /CS=1 to /CS=0 before starting communication. The transition high to low is mandatory.
If you always keep /CS=0 , you can't have communication master vs eeprom.
2020-07-06 01:19 AM
Thank you!