Question
W25Q256 write protection
Hi!
Why can i not disable the protection? I use W25Q256. I can't write and erase the flash ic.
The programming was working, but suddenly an error occurred during download. Here I noticed that the bits of SR 1 went to 1 and I can't reset them.
What could be the problem that I can't find?
I attached the picture from the readed registers.
Thank you!
Here is my code:
/* Enable Quad Mode & Set Dummy Cycles Count */
HAL_StatusTypeDef W25Q_QSPI_Configuration() {
uint8_t reg1 = 0, reg2 = 0, reg3 = 0;
uint8_t w_reg1 = 0, w_reg2 = 0, w_reg3 = 0;
if (W25Q_Read_Status_Registers(®1, 1) != HAL_OK) {
return HAL_ERROR;
}
if (W25Q_Read_Status_Registers(®2, 2) != HAL_OK) {
return HAL_ERROR;
}
if (W25Q_Read_Status_Registers(®3, 3) != HAL_OK) {
return HAL_ERROR;
}
#if W25Q_FLASH_SIZE > 0x1000000
// If ADP != 1
if(!((reg3 >> 1) & 0b1)) { // Check 1.bit
w_reg3 = reg3 | (1 << 1); // Set ADP 1.bit
}
// If ADS != 1
if(reg3 & 0b1) { // Check ADS 0.bit
W25Q_Enter4ByteMode(1); // Enter 4byte mode
}
#else
// If ADS != 1
if(((reg3 >> 0) & 1)) { // Check 0.bit
// Enter 4 byte mode
W25Q_Enter4ByteMode(0); // Exit 4byte mode
}
#endif
w_reg1 = 0x0; //reg1;
w_reg2 = reg2 | W25Q_SR_Quad_Enable;
w_reg3 = reg3 | 0xA9;
if (W25Q_Write_Status_Registers(w_reg1, 1) != HAL_OK) {
return HAL_ERROR;
}
if (W25Q_Write_Status_Registers(w_reg2, 2) != HAL_OK) {
return HAL_ERROR;
}
if (W25Q_Write_Status_Registers(w_reg3, 3) != HAL_OK) {
return HAL_ERROR;
}
return HAL_OK;
}
