![]() |
RAFW Flexible Software Package Documentation
Release v2.0.1
|
|
Driver for the QSPI peripheral on RRQ MCUs. This module implements the SPI Flash Interface.
The QSPI driver has the following key features:
| Configuration | Options | Default | Description |
|---|---|---|---|
| Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
| Configuration | Options | Default | Description |
|---|---|---|---|
| General | |||
| Name | Name must be a valid C symbol | g_qspi_w0 | Module name. |
| Channel | Channel not available on selected MCU | 0 | Module Channel. |
| Address Bytes |
| 3 | Select the number of address bytes. Selecting '4 with 4-byte read code' converts the default read code determined in Read Mode to the 4-byte version. If 4-byte mode is selected without using 4-byte commands, the application must issue the EN4B command using R_QSPI_W_Direct(). |
| Page Size Bytes | Must be an integer greater than 0 | 256 | The maximum number of bytes allowed for a single write. |
| Data Rate Mode | SDR | SDR | Select QSPI Mode. |
| Drive Current | MCU Specific Options | Set the Drive Strength of the QSPI Controller. | |
| Slew Rate | MCU Specific Options | Set the Slew Rate of the QSPI Controller. | |
| Data Cache | MCU Specific Options | Enable the dCache Controller. | |
| SPI Clock Polarity |
| Low | Select the polarity of QSPI_W_CLK when QSPI_W_CS is high. |
| Wrap Mode |
| module.driver.qspi_w.wrap_mode.disabled | Select if Wrapping Burst is enabled. |
| Memory Burst Length | MCU Specific Options | Set the external memory burst length of the QSPI Controller. | |
| Command Definitions | |||
| Command Definitions > Read Command | |||
| Read Mode Opcode | Value must be a non-negative integer | 0xEB | Select the read mode for memory mapped access. |
| Read Mode Wrapping Burst Opcode | Value must be a non-negative integer | 0 | Enter the read opcode for wrapping burst memory mapped access. |
| Extra Byte Value | Value must be a non-negative integer | 0xFF | Enter the value for the extra byte. |
| Extra Byte Enable |
| Disabled | Enable the transmission of the extra byte. |
| CS High Minimum Cycles | Value must be a non-negative integer | 0x01 | Between the transmissions of two different instructions to the memory device, the SPI bus stays in idle state (QSPI_CS high) for at least this number of QSPI_SCK clock cycles. |
| Instruction Opcode Bus Lines |
| 1 | Select the number of lines to use for sending the instruction's opcode. This can be determined by referencing the datasheet for the external QSPI. |
| Address & Dummy Data Bus Lines |
| 4 | Select the number of lines to use for the address bytes & dummy bytes. This can be determined by referencing the datasheet for the external QSPI. |
| Data Bus Lines |
| 4 | Select the number of lines to use for the data bytes. This can be determined by referencing the datasheet for the external QSPI. |
| Dummy Clocks | MCU Specific Options | Select the number of dummy clocks for fast read operations. Default is 6 clocks for Fast Read Quad I/O, 4 clocks for Fast Read Dual I/O, and 8 clocks for other fast read instructions including Fast Read Quad Output, Fast Read Dual Output, and Fast Read | |
| Instruction Mode |
| TX Instr At Any Burst Access | Select whether you want to transmit instruction at any burst access or only in the first access after the selection of Auto Mode. |
| Command Definitions > Page Program Command | |||
| Page Program Command Opcode | Must be an 8-bit QSPI Page Program Command | 0x02 | The command to program a page. If 'Support Multiple Line Program in Extended SPI Mode' is Enabled, this command must use the same number of data lines as the selected read mode. |
| Page Program Command Wrapping Burst Opcode | Value must be a non-negative integer | 0 | Enter the page program opcode for wrapping burst memory mapped access. |
| CS High Minimum Cycles | Value must be a non-negative integer | 0x01 | After the execution of the write command, the QSPI_CS remains high for at least this number of QSPI_SCK clock cycles. |
| Instruction Opcode Bus Lines |
| 1 | Select the number of lines to use for sending the instruction's opcode. This can be determined by referencing the datasheet for the external QSPI. It should either be 1 or match the number of data lines used for memory mapped fast read operations. |
| Address, Dummy Data & Data Bus Lines |
| 1 | Select the number of lines to use for the address bytes, dummy bytes & data bytes. This can be determined by referencing the datasheet for the external QSPI. It should either be 1 or match the number of data lines used for memory mapped fast read operations. |
| Dummy Clocks | MCU Specific Options | Select the number of dummy clocks for fast read operations. Default is 6 clocks for Fast Read Quad I/O, 4 clocks for Fast Read Dual I/O, and 8 clocks for other fast read instructions including Fast Read Quad Output, Fast Read Dual Output, and Fast Read | |
| Command Definitions > Status Command | |||
| Opcode | Must be an 8-bit QSPI Status Command | 0x05 | The command to query the status of a write or erase command. |
| Instruction Opcode Bus Lines |
| 1 | Select the number of lines to use for sending the instruction's opcode. This can be determined by referencing the datasheet for the external QSPI. It should either be 1 or match the number of data lines used for memory mapped fast read operations. |
| Receive Data Bus Lines |
| 1 | Select the number of lines to use for the received data bytes. This can be determined by referencing the datasheet for the external QSPI. |
| Write Status Bit Pos | Must be an integer between 0 and 7 | 0 | Which bit contains the write in progress status returned from the Write Status Command. |
| Command Definitions > Write Enable Command | |||
| Opcode | Must be an 8-bit QSPI Write Enable Command | 0x06 | The command to enable write. |
| Write Enable Bit Pos | Must be an integer between 0 and 7 | 1 | This bit will wait until the write data to be available before to start sending the write command sequence. |
| Data Bus Lines |
| 1 | Select the number of lines to use for the opcode byte. This can be determined by referencing the datasheet for the external QSPI. |
| Command Definitions > Erase Command | |||
| Sector Erase Opcode | Must be an 8-bit QSPI Sector Erase Opcode under Command Definitions|Erase Command | 0x20 | The command to erase a sector. Set Sector Erase Size to 0 if unused. |
| Sector Erase Size | Must be an integer greater than or equal to 0 | 4096 | The sector erase size. Set Sector Erase Size to 0 if Sector Erase is not supported. |
| Block Erase Opcode | Must be an 8-bit QSPI Block Erase Opcode under Command Definitions|Erase Command | 0xD8 | The command to erase a block. Set Block Erase Size to 0 if unused. |
| Block Erase Size | Must be an integer greater than or equal to 0 | 65536 | The block erase size. Set Block Erase Size to 0 if Block Erase is not supported. |
| Block Erase 32KB Opcode | Must be an 8-bit QSPI Block Erase 32KB Opcode under Command Definitions|Erase Command | 0x52 | The command to erase a 32KB block. Set Block Erase Size to 0 if unused. |
| Block Erase 32KB Size | Must be an integer greater than or equal to 0 | 32768 | The block erase 32KB size. Set Block Erase 32KB Size to 0 if Block Erase 32KB is not supported. |
| Chip Erase Opcode | Must be an 8-bit QSPI Chip Erase Opcode under Command Definitions|Erase Command | 0xC7 | The command to erase the entire chip. Set Chip Erase Command to 0 if unused. |
| Instruction Opcode Bus Lines |
| 1 | Select the number of lines to use for sending the instruction's opcode. This can be determined by referencing the datasheet for the external QSPI. It should either be 1 or match the number of data lines used for memory mapped fast read operations. |
| Dummy Data & Data Bus Lines |
| 1 | Select the number of lines to use for the address bytes, dummy bytes & data bytes. This can be determined by referencing the datasheet for the external QSPI. It should either be 1 or match the number of data lines used for memory mapped fast read operations. |
| Command Definitions > XIP Command | |||
| Enter Command | Must be an 8-bit QSPI XIP Enter M7-M0 command under Command Definitions|XIPCommand | 0xA5 | How to set M7-M0 to enter XIP mode. |
| Exit Command | Must be an 8-bit QSPI XIP Exit M7-M0 command under Command Definitions|XIPCommand | 0xFF | How to set M7-M0 exit XIP mode. |
The QSPI clock is derived from PCLKA.
The following pins are available to connect to an external QSPI device:
After R_QSPI_W_Open() completes successfully, the QSPI flash device contents are mapped to address 0x16000000 and can be read like on-chip flash.
This is a basic example of minimal use of the QSPI in an application.
This is an example of the types of commands that can be used to initialize the QSPI.
This is an example of using R_QSPI_W_DirectWrite followed by R_QSPI_W_DirectRead to send the read status register command and read back the status register from the device.
This is an example of using R_QSPI_W_DirectWrite followed by R_QSPI_W_DirectRead to query the device size.