FlexSPI usage for read/write non boot device

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

FlexSPI usage for read/write non boot device

201 Views
Eugene3
Contributor II

I'm designing a custom board with RT1170.

I connect a device which has QSPI interface on FlexSPI2.

I could read the data properly from the QSPI devices when I used Normal read mode or Fast read mode.

However the first byte became 0xFF if I tried to read by fast Quad mode.

Could you help me how to read properly by fast quad?

 

I'm not sure how to use LUT well.

	status_t status;
	SDK_ALIGN( static uint8_t s_nor_read_buffer[256], 4 );

    flexspi_nor_flash_init( EXAMPLE_FLEXSPI );

    /* Enter quad mode. */
    status = flexspi_nor_enable_quad_mode( EXAMPLE_FLEXSPI );
    if (status != kStatus_Success)
    {
        return status;
    }

	status = flexspi_nor_flash_read( EXAMPLE_FLEXSPI, start_addr , (void *)s_nor_read_buffer , sizeof( s_nor_read_buffer ));
    if (status != kStatus_Success)
    {
        return status;
    }
	return 0;
}


static const uint32_t flexspi_seq_cmd_lut_flash[FLEXSPI_SEQ_CMD_LUT_LENGTH] = {
	// Normal read mode -SDR
    [4 * NOR_CMD_LUT_SEQ_IDX_READ_NORMAL] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x03, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18),
    [4 * NOR_CMD_LUT_SEQ_IDX_READ_NORMAL + 1] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x04, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0),

	// Fast read mode - SDR
    [4 * NOR_CMD_LUT_SEQ_IDX_READ_FAST] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x0B, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18),
    [4 * NOR_CMD_LUT_SEQ_IDX_READ_FAST + 1] =
		FLEXSPI_LUT_SEQ( kFLEXSPI_Command_DUMMY_SDR, kFLEXSPI_1PAD, 0x08, kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x04),

	// Fast read quad mode - SDR
	[4 * NOR_CMD_LUT_SEQ_IDX_READ_FAST_QUAD] =
		FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xEB, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 0x18),
	[4 * NOR_CMD_LUT_SEQ_IDX_READ_FAST_QUAD + 1] =
		FLEXSPI_LUT_SEQ( kFLEXSPI_Command_DUMMY_SDR, kFLEXSPI_4PAD, 0x06, kFLEXSPI_Command_READ_SDR, kFLEXSPI_4PAD, 0x04 ),	// Transmit command/address and transmit/receive data only through DATA[3:0].

 

0 Kudos
5 Replies

153 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello
I hope you are well.

Are you writing/reading through IP commands? There are some issues when writing on AHB. Is cache enabled?
Regarding the LUT, it needs to be configured according to specific flash parameters and it may vary depending on the vendor.

Best regards,
Omar

0 Kudos

149 Views
Eugene3
Contributor II

Hi @Omar_Anguiano 

Thank you for your help.

Should I use IP command if I access to FlexSPI? What are issues on AHB?

Cache is enabled now.

 

Where should I refer to understand LUT? I'm not sure about the following highlighted arguments especially. 

Eugene3_0-1715042080015.png

 

 

0 Kudos

145 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Yes, it is suggested to use IP to write the flexspi. There are issues with writing through AHB on most flashes. 

For the LUT please refer to the chapter on the RM. An example of how to modify the LUT based on different flash is on this application note: How to Enable Debugging for FLEXSPI NOR Flash (nxp.com)

Best regards,
Omar

0 Kudos

106 Views
Eugene3
Contributor II

Hi @Omar_Anguiano 

Thank you for your information.

Do you have any documents or sample code for using IP command?

I couldn't figure out how to switch from AHB to IP and how to map memory address for IP access.

 

0 Kudos

100 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

You can check the SDK examples, the flexspi examples specifically uses IP commands to read/write the flash. AHB is accessed when you read specifically the FlexSPI mapped address. 

Best regards,
Omar

0 Kudos