writing to flash non-volatile register

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

writing to flash non-volatile register

234 Views
syed1
Contributor I

Hello

I'm using MIMXRT1011 processor and MCU expresso ide tool. I want to enable xip mode bit in the external flash (MT25QUA512BB). They have provided the command code for reading and writing non-volatile configuration register. I'm using flexspi_nor_polling_transfer example. I want to read and write the register through this example, but there are no particular functions for reading and writing the registers. For example, there is a function called flexspi_nor_get_vendor_id for getting vendor id. In this way do this example have any functions for reading and writing registers of external flash.

 

0 Kudos
4 Replies

209 Views
Habib_MS
NXP Employee
NXP Employee

Hello @syed1,

To write an external memory the driver flexspi_nor_flash_ops.c provides the function called "flexspi_nor_flash_program", you can see the driver to obtain more information about how to use this function.

Also, the same driver provides a function to read a section of a NOR FLASH, this function is called "flexspi_nor_flash_read", At the same time, you can see the driver to obtain more information about how to use this function.

BR,
Habib.

0 Kudos

200 Views
syed1
Contributor I

Hello 

Thank you for reaching out.

The MT25 flash datasheet did not provided any address of the volatile and non-volatile registers. In the function you mentioned, require destination address of these registers. Could you please provide the solution for this?

BR 

Syed. 

0 Kudos

179 Views
Habib_MS
NXP Employee
NXP Employee

Hello again @syed1,

 

unfortunately, the function of the SDK needs a destination address. To obtain that, you can get information directly with Micron.

Sorry for the inconvenience this may cause.

 

Also, if you experience any issue, do not hesitate to let me know.

BR

Habib.

0 Kudos

167 Views
syed1
Contributor I

Hello again @Habib_MS 

Thank you for reaching out to me.

I could read the values in non-volatile and volatile register by using the following function but couldn't write to it. 

status_t flexspi_nor_read(FLEXSPI_Type *base, uint8_t *value)

{

uint32_t temp1;

flexspi_transfer_t flashXfer;

flashXfer.deviceAddress = 0;

flashXfer.port = FLASH_PORT;

flashXfer.cmdType = kFLEXSPI_Read;

flashXfer.SeqNumber = 1;

flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_READNONVOLATILEREG;

flashXfer.data = &temp1;

flashXfer.dataSize = 1;

 

status_t status = FLEXSPI_TransferBlocking(base, &flashXfer);

 

*value = temp1;

 

/* Do software reset or clear AHB buffer directly. */

#if defined(FSL_FEATURE_SOC_OTFAD_COUNT) && defined(FLEXSPI_AHBCR_CLRAHBRXBUF_MASK) && \

defined(FLEXSPI_AHBCR_CLRAHBTXBUF_MASK)

base->AHBCR |= FLEXSPI_AHBCR_CLRAHBRXBUF_MASK | FLEXSPI_AHBCR_CLRAHBTXBUF_MASK;

base->AHBCR &= ~(FLEXSPI_AHBCR_CLRAHBRXBUF_MASK | FLEXSPI_AHBCR_CLRAHBTXBUF_MASK);

#else

FLEXSPI_SoftwareReset(base);

#endif

 

return status;

}

by calling this function in main file as below

 

status = flexspi_nor_read(EXAMPLE_FLEXSPI, &value);

if (status != kStatus_Success)

{

return status;

}

PRINTF("Value: 0x%x\r\n", value);

 

for writing to the volatile register I have used the following function.

status_t WRITE_REG(FLEXSPI_Type *base)

{

flexspi_transfer_t flashXfer;

status_t status;

#if defined(FLASH_QUAD_ENABLE) && FLASH_QUAD_ENABLE

uint32_t writeValue = VALUE;

 

#endif

 

#if defined(CACHE_MAINTAIN) && CACHE_MAINTAIN

flexspi_cache_status_t cacheStatus;

flexspi_nor_disable_cache(&cacheStatus);

#endif

 

/* Write enable */

status = flexspi_nor_write_enable1(base, 0);

 

if (status != kStatus_Success)

{

return status;

}

 

/* Enable quad mode. */

flashXfer.deviceAddress = 0;

flashXfer.port = FLASH_PORT;

#if defined(FLASH_QUAD_ENABLE) && FLASH_QUAD_ENABLE

flashXfer.cmdType = kFLEXSPI_Write;

flashXfer.SeqNumber = 1;

flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_WRITEVOLATILEREG;

flashXfer.data = &writeValue;

flashXfer.dataSize = 1;

#endif

#if defined(MT25Q_FLASH_QUAD_ENABLE) && MT25Q_FLASH_QUAD_ENABLE

flashXfer.cmdType = kFLEXSPI_Command;

flashXfer.SeqNumber = 1;

flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_ENABLEQUAD;

#endif

status = FLEXSPI_TransferBlocking(base, &flashXfer);

if (status != kStatus_Success)

{

return status;

}

 

status = flexspi_nor_wait_bus_busy(base);

 

/* Do software reset. */

FLEXSPI_SoftwareReset(base);

 

#if defined(CACHE_MAINTAIN) && CACHE_MAINTAIN

flexspi_nor_enable_cache(cacheStatus);

#endif

 

return status;

}

 While debugging, no errors are thrown. However, when attempting to read back the register, I receive a default value instead."

0 Kudos