NOR FLASH SPI1 communication issue with STM32F446RET6 - JEDEC ID reads incorrectly
I am learning STM32 using the F446RET6 board. I'm facing an issue while connecting a W25Q64 NOR FLASH memory via SPI1 to the board. The JEDEC ID should be 20 70 17, but the STM32 consistently receives incorrect data: 3F FF FF.
The connections are VCC to 3.3V, GND to GND, SCLK to PA5 (SPI1_SCK), D0/DO to PA6 (SPI1_MISO), D1/DI to PA7 (SPI1_MOSI), and CS to PC7 as a GPIO output.
SPI1 is configured as Master, Full Duplex, 8-bit, CPOL Low, CPHA 1st Edge, MSB First, Software NSS, with a prescaler of 32. CS is manually controlled using PC7.
The HAL SPI transaction completes successfully, but the returned JEDEC ID is incorrect. The same W25Q64 module works perfectly with an ESP8266, where I get the expected 20 70 17, so the flash itself appears to be working.
I also tested PA5, PA6, PA7 and PB6 separately as GPIO outputs using a multimeter. All of them can correctly output both HIGH (~3.3V) and LOW (~0V). PC7 also switches correctly between ~3.3V and 0V when used as CS.
I initially used a breadboard for the SPI connections and noticed some inconsistent behavior, so I also tried connecting the SPI lines directly to different sections of the PCB, but the problem remained.
I have ordered an 8-channel logic analyzer to inspect CS, SCLK, MOSI and MISO. Before it arrives, I would like to know if there is anything obvious I am missing in the STM32 SPI configuration, wiring, or HAL implementation, and whether this could indicate a problem with SPI1 itself.