I can't programm MT25QL512ABB8ESF-0SIT flash on STM32H747I-DISCO Discovery kit
Hello!
I can read any registers, but can't proramm it. This is my first attempt to work whith this flash in this KIT. Initialization - HAL, STMCube IDE.
Code in main function after Initialization (initialization - auto generate in IDE):
QSPI_Write_en_Command(ONE_LINE_MODE);
QSPI_Init_Command(ONE_LINE_MODE);
QSPI_Read_Register(FLAG_STATUS_REGISTER,qspi2rd,1,ONE_LINE_MODE);
QSPI_Read_Register(READ_STATUS,qspi2rd+1,1,ONE_LINE_MODE);
QSPI_Read_Volatile_Reg(qspi2rd+2, ONE_LINE_MODE);
where:
void QSPI_Write_en_Command(uint32_t Mode){
uint32_t InstructionMode;
if ((Mode==ONE_LINE_MODE)||(Mode==EXTENDED_MODE)){
InstructionMode=QSPI_INSTRUCTION_1_LINE;
}
else if (Mode==QUAD_MODE){
InstructionMode=QSPI_INSTRUCTION_4_LINES;
}
else{
InstructionMode=QSPI_INSTRUCTION_2_LINES;
}
QSPI_Command.Instruction=WRITE_ENABLE;
QSPI_Command.AddressSize=0x0;
QSPI_Command.AlternateBytesSize=0x0;
QSPI_Command.DummyCycles=0x0;
QSPI_Command.InstructionMode=InstructionMode;
QSPI_Command.AddressMode=QSPI_ADDRESS_NONE;
QSPI_Command.AlternateByteMode=QSPI_ALTERNATE_BYTES_NONE;
QSPI_Command.DataMode=QSPI_DATA_NONE;
QSPI_Command.NbData=0x0;
QSPI_Command.DdrMode=QSPI_DDR_MODE_DISABLE;
QSPI_Command.DdrHoldHalfCycle=QSPI_DDR_HHC_ANALOG_DELAY;
QSPI_Command.SIOOMode=QSPI_SIOO_INST_EVERY_CMD;
HAL_QSPI_Command(&hqspi,&QSPI_Command,2);
}
oid QSPI_Init_Command(uint32_t Mode){
static uint8_t volatile_conf_reg=0x1B;
static uint8_t enhanced_volatile_conf_reg=0xEF;
uint32_t InstructionMode;
uint32_t DataMode;
if (Mode==ONE_LINE_MODE){
InstructionMode=QSPI_INSTRUCTION_1_LINE;
DataMode=QSPI_DATA_1_LINE;
}
else if (Mode==QUAD_MODE){
InstructionMode=QSPI_INSTRUCTION_4_LINES;
DataMode=QSPI_DATA_4_LINES;
}
else if (Mode==DUAL_MODE){
InstructionMode=QSPI_INSTRUCTION_2_LINES;
DataMode=QSPI_DATA_2_LINES;
}
else{
InstructionMode=QSPI_INSTRUCTION_1_LINE;
DataMode=QSPI_DATA_4_LINES;
}
QSPI_Command.Instruction=VOLATILE_REG_COM;
QSPI_Command.AddressSize=0x0;
QSPI_Command.AlternateBytesSize=0x0;
QSPI_Command.DummyCycles=0x1;
QSPI_Command.InstructionMode=InstructionMode;
QSPI_Command.AddressMode=QSPI_ADDRESS_NONE;
QSPI_Command.AlternateByteMode=QSPI_ALTERNATE_BYTES_NONE;
QSPI_Command.DataMode=DataMode;
QSPI_Command.NbData=0x1;
QSPI_Command.DdrMode=QSPI_DDR_MODE_DISABLE;
QSPI_Command.DdrHoldHalfCycle=QSPI_DDR_HHC_ANALOG_DELAY;
QSPI_Command.SIOOMode=QSPI_SIOO_INST_EVERY_CMD;
HAL_QSPI_Command(&hqspi,&QSPI_Command,2);
HAL_QSPI_Transmit(&hqspi,&volatile_conf_reg,2);
QSPI_Command.Instruction=ENHANCED_VOLATILE_COM;
HAL_QSPI_Command(&hqspi,&QSPI_Command,2);
HAL_QSPI_Transmit(&hqspi,&enhanced_volatile_conf_reg,2);
}
void QSPI_Read_Register(uint32_t command, uint8_t *data, uint32_t length, uint32_t Mode){
uint32_t InstructionMode;
uint32_t DataMode;
if (Mode==ONE_LINE_MODE){
InstructionMode=QSPI_INSTRUCTION_1_LINE;
DataMode=QSPI_DATA_1_LINE;
}
else if (Mode==QUAD_MODE){
InstructionMode=QSPI_INSTRUCTION_4_LINES;
DataMode=QSPI_DATA_4_LINES;
}
else if (Mode==DUAL_MODE){
InstructionMode=QSPI_INSTRUCTION_2_LINES;
DataMode=QSPI_DATA_2_LINES;
}
else{
}
QSPI_Command.Instruction=command;
QSPI_Command.Address = 0;
QSPI_Command.AddressSize=QSPI_ADDRESS_24_BITS;
QSPI_Command.AlternateBytesSize=0x0;
QSPI_Command.DummyCycles=0x0;
QSPI_Command.InstructionMode=InstructionMode;
QSPI_Command.AddressMode=QSPI_ADDRESS_NONE;
QSPI_Command.AlternateByteMode=QSPI_ALTERNATE_BYTES_NONE;
QSPI_Command.DataMode=DataMode;
QSPI_Command.NbData=length;
QSPI_Command.DdrMode=QSPI_DDR_MODE_DISABLE;
QSPI_Command.DdrHoldHalfCycle=QSPI_DDR_HHC_ANALOG_DELAY;
QSPI_Command.SIOOMode=QSPI_SIOO_INST_EVERY_CMD;
HAL_QSPI_Command(&hqspi,&QSPI_Command,10);
HAL_QSPI_Receive(&hqspi,data,10);
}
void QSPI_Read_Volatile_Reg(uint8_t *data, uint32_t Mode){
uint32_t InstructionMode;
uint32_t DataMode;
if (Mode==ONE_LINE_MODE){
InstructionMode=QSPI_INSTRUCTION_1_LINE;
DataMode=QSPI_DATA_1_LINE;
}
else if (Mode==QUAD_MODE){
InstructionMode=QSPI_INSTRUCTION_4_LINES;
DataMode=QSPI_DATA_4_LINES;
}
else{
InstructionMode=QSPI_INSTRUCTION_2_LINES;
DataMode=QSPI_DATA_2_LINES;
}
QSPI_Command.Instruction=READ_VOL_REG;
QSPI_Command.Address = 0;
QSPI_Command.AddressSize=QSPI_ADDRESS_24_BITS;
QSPI_Command.AlternateBytesSize=0x0;
QSPI_Command.DummyCycles=0x0;
QSPI_Command.InstructionMode=InstructionMode;
QSPI_Command.AddressMode=QSPI_ADDRESS_NONE;
QSPI_Command.AlternateByteMode=QSPI_ALTERNATE_BYTES_NONE;
QSPI_Command.DataMode=DataMode;
QSPI_Command.NbData=1;
QSPI_Command.DdrMode=QSPI_DDR_MODE_DISABLE;
QSPI_Command.DdrHoldHalfCycle=QSPI_DDR_HHC_ANALOG_DELAY;
QSPI_Command.SIOOMode=QSPI_SIOO_INST_EVERY_CMD;
HAL_QSPI_Command(&hqspi,&QSPI_Command,2);
HAL_QSPI_Receive(&hqspi,data,2);
QSPI_Command.Instruction=READ_ENH_VOL_REG;
HAL_QSPI_Command(&hqspi,&QSPI_Command,2);
HAL_QSPI_Receive(&hqspi,data+1,2);
}
Defines in quadspi.h
#define NONVOLATILE_REG_COM 0xB1
#define VOLATILE_REG_COM 0x81
#define ENHANCED_VOLATILE_COM 0x61
#define WRITE_ENABLE 0x06
#define WRITE_DISABLE 0x04
#define BULK_ERASE 0xC7
#define PAGE_PROGRAMM 0x02
#define FAST_QUAD_PROGRAM 0x32
#define FAST_READ 0x0B
#define EXT_QUAD_INPUT_FAST_PROGRAM 0x38
#define QUAD_IO_MODE 0x35
#define RESET_MEMORY 0x99
#define RESET_ENABLE 0x66
#define READ_NONVOLATILE_REG 0xB5
#define READ_STATUS 0x05
#define QUAD_IOFAST_READ 0xEB
#define READ 0x03
#define READ_VOL_REG 0x85
#define READ_ENH_VOL_REG 0x65
#define READ_DEVICE_ID 0x9F
#define EARSE_NONVOLATILE_LOCK_BITS 0xE4
#define GLOBAL_FREEZE_BIT 0xA7
#define READ_VOLATILE_LOCK_BITS 0xE8
#define READ_NONVOLATILE_LOCK_BITS 0xE2
#define WRITE_GLOBAL_FREEZE_BIT 0xA6
#define FLAG_STATUS_REGISTER 0x70
#define RELEASE_FROM_DEEP_POWERDOWN 0xAB
#define MT_FLASH_SIZE 0x8000000
#define EXTENDED_MODE 0x3
#define QUAD_MODE 0x2
#define DUAL_MODE 0x1
#define ONE_LINE_MODE 0x0
There are no any warnings, or errors during compilation.
Then i sent data (qspi2rd[]) to USB. Result: flag status regiter = 0x80 (ready, no errors), status register = 0x02 (Write enable latch set). But in Volatile configuration register and Enhanced Volatile Configuration Register 0xFB and 0xFF respectively. Oscillogram accordingly Micron Serial NOR Flash Memory datasheet. Where my mistake? Mey be i must sent any other command? Nonvolatile Configuration Register = 0xFFFF (default state).