The following sequence can be followed:
- SetupOSPI_CONFIG_REG register.
- Setup the indirect transfer’s FLASH start address
in theOSPI_INDIRECT_WRITE_XFER_START_REG register.
- Setup the number of bytes to be transferred in
the OSPI_INDIRECT_WRITE_XFER_NUM_BYTES_REG register.
- Setup the indirect transfer’s trigger address in
the OSPI_IND_AHB_ADDR_TRIGGER_REG register.
- Setup the indirect transfer's trigger address
range in the OSPI_INDIRECT_TRIGGER_ADDR_RANGE_REG register.
- It is functionally valid for software to simply write all the data to the SRAM in one block transfer. However, if the total number of bytes to write is greater than the size of the partitioned SRAM, then it is quite likely the SRAM will become full causing the OSPI to back-pressure the system data bus for a considerable time. This time is based on the FLASH data-rate and the page-write time of the device. To avoid sending all the write data in one block transfer, software can make use of the watermark interrupt to identify a convenient time to send data a page at a time to the SRAM module. Alternatively, software can poll the SRAM fill level register directly to identify how empty the SRAM is at any one time in order to make a judgment as to when the most practical time to send the next part of the transfer.
- If the watermark interrupt feature is to be used,
set the OSPI_INDIRECT_WRITE_XFER_WATERMARK_REG register which will cause an
interrupt to be generated when the fill level falls below the watermark. The
watermark should be set to a number between zero and a page size. That is if
the page size is 256 bytes, then setting the watermark to a value between 10
and 250 is reasonable and will cause the interrupt to trigger when the fill
level drops below the programmed number. Setting the watermark can be useful
to provide an indication to software when to write the next page of data to
the SRAM.
- Trigger Indirect Write access by setting
OSPI_INDIRECT_WRITE_XFER_CTRL_REG[0] START_FLD bit.
- If the remaining number of bytes still to be transferred into the SRAM for the current indirect transfer is greater than a FLASH page, then write 1 FLASH page worth of data to the SRAM. Otherwise send the remaining data from the indirect transfer to SRAM.
- If all the data in the indirect transfer has now been sent to the SRAM, then go to 12 and await indirect complete status. Otherwise if there is more data still to be transferred then either:
- If the watermark interrupt feature is being used, then wait for watermark interrupt.
- Alternatively the SRAM fill level can be interrogated to identify a convenient time to send more data.
- Loop back to 9.
- Optional: The completion status of the Indirect
write operation can be polled via OSPI_INDIRECT_WRITE_XFER_CTRL_REG[5]
IND_OPS_DONE_STATUS_FLD.
- An Indirect Complete interrupt will be generated when the Indirect write operation has completed.