Question
STM32L071CB SPI Driver for MX25L8035F
Dear experts,
I bought a MX25V8035F chip. I try to build my own SPI driver to communicate with this chip. I use STM32L071cb, STM32CubeIDE, and HAL Libraries right now. But, the STM32L071cb always receives a random number. for example, I try to read the status register of MX25V8035F by sending 0x05 hex from the mcu. the output may be 0x00, 0x03, or 0xFF.
could you help me to find the problem ? Thank you guys.
Mahendra
------
the code
// STM32L071cb
#define RDSR 0x05
#define SPI1_CS_Pin GPIO_PIN_4
#define SPI1_CS_GPIO_Port GPIOA
uint8_t receive[8];
uint8_t command = RDSR;
// CS# goes low
HAL_GPIO_WritePin ( SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET );
// sending RDSR instruction code
HAL_SPI_Transmit ( &hspi1, (uint8_t *)&command, 1, 100 );
// Status Register data out on SO
HAL_SPI_Receive ( &hspi1, (uint8_t *)receive, 1, 100 );
// CS# goes high
HAL_GPIO_WritePin ( SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_SET );
// print the received bytes
USART_PutString ( &huart2, "0x%02X\r\n", receive[0] );
// reset the buffer
memset(receive, 0, sizeof(receive));the output

