NOR memory stop working after changing nonvolatile configuration register
Hello,
Im using STM32H745 on custom board, with Micron Flash Memory (MT25QU512ABB)
Board is tested, I was able to manage NOR memory through QSPI.
I tried to change nonvolatile configuration register to set two things:
- Number of address bytes during command entry to 4-byte address mode
- Enable Quad I/O protocol
This is code I used:
uint8_t QSPI_Set_Nonvolatile_Reg_Config(void) {
QSPI_CommandTypeDef sCommand;
uint8_t test_buffer[4] = { 0 };
/*read configuration register*/
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = 0xB5; //READ NONVOLATILE CONFIGURATION REGISTER
sCommand.AddressMode = QSPI_ADDRESS_NONE;
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
sCommand.DataMode = QSPI_DATA_1_LINE;
sCommand.DummyCycles = 0;
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
sCommand.NbData = 2;
if (HAL_QSPI_Command(&hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE)
!= HAL_OK) {
return HAL_ERROR;
}
if (HAL_QSPI_Receive(&hqspi, test_buffer, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.AddressSize = QSPI_ADDRESS_24_BITS;
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
sCommand.Instruction = 0xB1; //WRITE NONVOLATILE CONFIGURATION REGISTER
sCommand.AddressMode = QSPI_ADDRESS_NONE;
sCommand.DataMode = QSPI_DATA_1_LINE;
sCommand.DummyCycles = 0;
sCommand.NbData = 2;
//modify buffer to enable quad mode
//0b1111 1111 1111 0110
//MODIFY_REG(test_buffer[1], 0x9, 0x0);
test_buffer[0] = 0xFF;
test_buffer[1] = 0xF6;
// On the first try, i didnt use QSPI__WriteEnable(), that maybe my main error
// if (QSPI_WriteEnable() != HAL_OK) {
// return HAL_ERROR;
// }
if (HAL_QSPI_Command(&hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE)
!= HAL_OK) {
return HAL_ERROR;
}
if (HAL_QSPI_Transmit(&hqspi, test_buffer, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
Error_Handler();
return HAL_ERROR;
}
/*read configuration register*/
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = 0xB5; //READ NONVOLATILE CONFIGURATION REGISTER
sCommand.AddressMode = QSPI_ADDRESS_NONE;
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
sCommand.DataMode = QSPI_DATA_1_LINE;
sCommand.DummyCycles = 0;
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
sCommand.NbData = 2;
if (HAL_QSPI_Command(&hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
if (HAL_QSPI_Receive(&hqspi, test_buffer, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
return HAL_OK;
}First time I used it, i didn't use QSPI_WriteEnable command.
Yet, after I run QSPI_Set_Nonvolatile_Reg_Config(), everything stopped working.
In this code, AutoPolling started returning error, because of timeout (it didnt get StatusMatch flag), so my code doesnt go any futher.
Diffrent code I run on this board, where I had this memory working as intended, it also stopped working after change to this register, and reading memory gives somewhat random values(i didnt find any meaning in this mess). Erase and Write also no longer works.
The thing is, when I use QSPI_Set_Nonvolatile_Reg_Config() just to read this register, its 0xFFFF, like I didnt change anything (i need it set to 0xFFF6).
Tried to change this register many times, later adding WriteEnable command, but to no avail. It always reads 0xFFFF, even right after supposed change.
So, it looks like nothing is changed, yet nothing works anymore.
Is there some way to reset memory to its fabric settings, or maybe I permamently damage it?
I will be grateful for any kind of help,
Andrew
