Open Rajkumar181 opened 3 years ago
Hi, sorry for the late response.
It can be hard to tell what exactly is going wrong when an interface like this returns 0xFF or 0x00. It could mean that the memory has been erased and every byte has a value of 0xFF, or it could be because the chip isn't responding at all and there's a pull-up on the line.
But I'm sorry to say that I don't think I can help you with this issue. This is a bare-metal example, and you appear to be using the HAL distributed by ST. Unfortunately, I don't know very much about that library. It also looks like you are using the SPI peripheral, not the Quad-SPI one.
I'm sorry that I can't be more help, but if you wanted to try adapting this code to an STM32L4, you probably wouldn't need to make many changes to the peripheral configuration; it looks like they use the same kind of QSPI peripheral registers as the STM32F7 family. I have been thinking that it would be nice to have a more affordable option for this example, and an L432KC nucleo board with a W25Q chip would be a good fit for that, but I've been a little busy lately. I'll update this issue if I can find time for that, but no promises and it might be awhile.
I want to integrate with STM32L432KC, I have read your document https://vivonomicon.com/2020/08/08/bare-metal-stm32-programming-part-12-using-quad-spi-flash-memory/ , When I am reading the W25Q16 manufacturing ID, I got 0xFF. And what could be the issue?
/ 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_4;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 10;
hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
if (HAL_SPI_Init(&hspi1) != HAL_OK)
{
Error_Handler();
}
/ /main code
void manufacturerID(void)
{
uint8_t ID[4];
int i=0;
uint8_t cmd[4] = {READ_ID_CMD,0x00,0x00,0x00};
HAL_GPIO_WritePin(SPI_SEL2_GPIO_Port,SPI_SEL2_Pin,0);
HAL_SPI_TransmitReceive(&_W25QXX_SPI,&cmd[0],&ID[0],4,10);
HAL_GPIO_WritePin(SPI_SEL2_GPIO_Port,SPI_SEL2_Pin,1);
if((ID[0] != 0xEF) | (ID[1] != 0x17))
{
Error_Handler();
}
else
{
printf("W25Qxxx ID is : ");
for(i=0;i<2;i++)
{
printf("0x%02X ",ID[i]);
}
printf("\r\n\r\n");
}
}