Skip to main content
Graduate
September 10, 2024
Question

W25Q256 write protection

  • September 10, 2024
  • 1 reply
  • 4179 views

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(&reg1, 1) != HAL_OK) {
		return HAL_ERROR;
	}
	if (W25Q_Read_Status_Registers(&reg2, 2) != HAL_OK) {
	 return HAL_ERROR;
	}
	if (W25Q_Read_Status_Registers(&reg3, 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;
}

 

 

    This topic has been closed for replies.

    1 reply

    Graduate II
    September 10, 2024

    Some of the older parts SR1 and SR2 must write as a pair.

    The high order bit in SR1 clears via a power cycle, once set you can't change the other bits.

    Yes, need to clear the BPx bits and COM

    Seen a number of people jam up the parts this way.

    Graduate
    September 10, 2024

    Can you help me with what exactly I have to do to make the ic work again, what is the solution to this error? I tried quite a few things but it didn't work. Thanks