STM32g070 wrong data reading EEPROM on W25Q128FV
Hi, I am trying to read the contents of the EEPROM on this W25Q128FVIQ. I am using SPI.
The data read looked wrong to me, and the Manufacture ID I am getting out of it is wrong. I am getting 0xDC instead of 0xEF.
I tried reading and writing data with a 4KB Microchip 25AA040A and that seemed to work fine. I wrote in 0xAB 0xCD and 0xEF and read it out successfully.
Test4 is the one for reading the Manufacture ID on the Winbond chip.
Also when I send it an address(not required for reading the Manufacture ID), I believe the chip is expecting it in Big Endian, so I believe I have to reverse the byte order of the address correct?
But again, test4(marked in the code) is the one I am most concerned with right now.
I should be reading 0xEF, but I get 0xDC
if(test == 4) { //read jedec id, test4
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
HAL_Delay(10);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, (uint8_t *)&EEPROM_RJEDEC, 1, 100);
HAL_SPI_Receive(&hspi1, (uint8_t *)uart_buf, 3, 100);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
for(int i = 0; i <3; i++)
printf("JEDEC MFR ID is %X\n", uart_buf[i]);
}SPI cubemx code:
static void MX_SPI1_Init(void)
{
/* USER CODE BEGIN SPI1_Init 0 */
/* USER CODE END SPI1_Init 0 */
/* USER CODE BEGIN SPI1_Init 1 */
/* USER CODE END SPI1_Init 1 */
/* SPI1 parameter configuration*/
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 7;
hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
if (HAL_SPI_Init(&hspi1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI1_Init 2 */
/* USER CODE END SPI1_Init 2 */
}const uint8_t EEPROM_READ = 0x03;
const uint8_t EEPROM_WRITE = 0x02;
const uint8_t EEPROM_WRDI = 0x04;
const uint8_t EEPROM_WREN = 0x06;
const uint8_t EEPROM_RDSR = 0x05;
const uint8_t EEPROM_RDSR2 = 0x35;
const uint8_t EEPROM_RDSR3 = 0x15;
const uint8_t EEPROM_WRSR = 0x01;
const uint8_t EEPROM_RMFR = 0x90;
const uint8_t EEPROM_RJEDEC = 0x9F;
ConstantsI am using jumper wire on a bread board, but the results are always consistent, so I don't think it is a wiring problem?
Here is the data sheet for the chip https://www.winbond.com/resource-files/w25q128fv rev.m 05132016 kms.pdf
Thanks
