I have a problem. My EEPROM is 93lc66b. I am doing the following to write and after that, read the data.
uint16_t Inst_EWEN = 0x9800;
uint16_t Inst_WRITE = 0xA01F;
uint16_t Inst_Read = 0xC000;
uint16_t dataIn = 2;
uint8_t dataForUart[20];
int messageLength;
//Switch off CS
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET);
HAL_Delay(100);
//switch on CS for EWEN
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET);
HAL_SPI_Transmit(&hspi2, &Inst_EWEN, 1, 1000);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET);
HAL_Delay(0.3);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET);
HAL_SPI_Transmit(&hspi2, &Inst_WRITE, 1, 1000);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET);
///////////////////////////////////////////////////////////////////////////////////
//Switch on CS for read
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET);
HAL_SPI_Transmit(&hspi2, &Inst_Read, 1, 1000);
HAL_SPI_Receive(&hspi2, &dataIn, 1, 1000);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET);
HAL_Delay(100);
///////////////////////////////////////////////////////////////////////////////////
//Send to Uart na UART'a
messageLength = sprintf(&dataForUart,"Read data: %d", dataIn);
HAL_UART_Transmit(&hlpuart1, &dataForUart, messageLength, 1000);`
After executing this function I got 0. I don't know whether I understand the datasheet. First I have to send EWEN operation (1001100000000000 -0x9800). Next Write operation (1010000000011111 - 0xA01F) and next Read operation (1100000000000000 - 0xC000). Maybe I have bad understanding how bits work ?