Why is the data I write through the QSPI interface different from the data actually captured on the line?

We used nRF5340 as the controller to develop a product for our customer, which requires a QSPI interface of 5340 to drive a screen. However, during testing, we found that the data captured from the default QSPI interface of the development board was completely different from the data we sent through the program. Moreover, no matter how we modified the program, its data was still the same. What is the reason for this? 

static void LCD_QSPI_Init(void)
{
	nrfx_qspi_config_t QSPIconfig;

	/* Configure XIP offset */
	QSPIconfig.xip_offset = 0;
	QSPIconfig.skip_gpio_cfg=false;
	QSPIconfig.skip_psel_cfg=false;

	/* Configure pins */
	QSPIconfig.pins.sck_pin = 17;
	QSPIconfig.pins.csn_pin = 18;
	QSPIconfig.pins.io0_pin = 13;
	QSPIconfig.pins.io1_pin = 14;
	QSPIconfig.pins.io2_pin = 15;
	QSPIconfig.pins.io3_pin = 16;

	QSPIconfig.prot_if.readoc = NRF_QSPI_READOC_FASTREAD;
	QSPIconfig.prot_if.writeoc = NRF_QSPI_WRITEOC_PP4O;
	QSPIconfig.prot_if.addrmode = NRF_QSPI_ADDRMODE_24BIT;
	QSPIconfig.prot_if.dpmconfig = false;

	/* Configure physical interface */
 	QSPIconfig.phy_if.sck_freq = NRF_QSPI_FREQ_DIV16;
	QSPIconfig.phy_if.sck_delay = 0x05;
	QSPIconfig.phy_if.spi_mode = NRF_QSPI_MODE_0;

	QSPIconfig.phy_if.dpmen = false;

	nrfx_err_t err_code = nrfx_qspi_init(&QSPIconfig, LCD_QSPI_handler, NULL);
	if(err_code != NRFX_SUCCESS)
	{
		LOGD("QSPI initialization failed with error: %d\n", err_code);
		return;
	}
	else
	{
		LOGD("QSPI initialized successfully");
	}
}
  
void WriteComm(uint8_t cmd, uint8_t *data, uint8_t data_len)
{
	uint32_t len = 4;
	uint8_t tx_buff[8];
	nrfx_err_t res;
	nrf_qspi_cinstr_conf_t cfg = { 
									.opcode    = 0x02,
									.io2_level = false,
									.io3_level = false,
									.wipwait   = false,
									.wren	   = false
								};

	gpio_pin_set(gpio_lcd, RS, 0);
	
	tx_buff[0] = 0x00;
	tx_buff[1] = cmd;
	tx_buff[2] = 0x00;

#ifdef LCD_TYPE_QSPI
	if(data_len < ARRAY_SIZE(cmd_cinstr_len))
	{
		cfg.length = cmd_cinstr_len[data_len];

		memcpy(&tx_buff[3], data, data_len);
		res = nrfx_qspi_cinstr_xfer(&cfg, tx_buff, NULL);
		if(res == NRFX_SUCCESS)
		{
			LOGD("nrfx_qspi_cinstr_xfer success!");
		}
		else
		{
			LOGD("nrfx_qspi_cinstr_xfer fail!res:%d", res);
		}
	}
	else
	{
		cfg.length = NRF_QSPI_CINSTR_LEN_1B;
		size_t len_1;

		res = nrfx_qspi_lfm_start(&cfg);
		if(res == NRFX_SUCCESS)
		{
			LOGD("nrfx_qspi_lfm_start success!");
		}
		else
		{
			LOGD("nrfx_qspi_lfm_start fail!res:%d", res);
		}

		len_1 = sizeof(tx_buff) - 3;
		memcpy(&tx_buff[3], data, len_1);

		if(res == NRFX_SUCCESS)
		{
			res = nrfx_qspi_lfm_xfer(tx_buff, NULL, sizeof(tx_buff), false);
			if(res == NRFX_SUCCESS)
			{
				LOGD("nrfx_qspi_lfm_xfer 001 success!");
			}
			else
			{
				LOGD("nrfx_qspi_lfm_xfer 001 fail!res:%d", res);
			}
		}

		if(res == NRFX_SUCCESS)
		{
			res = nrfx_qspi_lfm_xfer(data + len_1, NULL, data_len - len_1, true);
			if(res == NRFX_SUCCESS)
			{
				LOGD("nrfx_qspi_lfm_xfer 002 success!");
			}
			else
			{
				LOGD("nrfx_qspi_lfm_xfer 002 fail!res:%d", res);
			}
		}
	}

	//LCD_QSPI_Transceive(buf, len, NULL, 0);

#elif defined(LCD_TYPE_SPI)
	if(data != NULL && data_len > 0)
	{
		memcpy(&tx_buff[4], data, data_len);
		len += data_len;
	}

	LCD_SPI_Transceive(tx_buff, len, NULL, 0);
#endif

	gpio_pin_set(gpio_lcd, RS, 1);
}

We issued a 0xff command, but the actual data sent on the line is as shown in the screenshot:

Parents
  • Reason is that the QSPI peripherial does not support anything other than some NOR flash chips that it is tailored for.

    Read the PS for details - you will likely need to change the design.

    Scope picture looks like a "read status" (RDSR) opcode to me. That one might be baked into either the hardware or the NRFX code - which one I am not sure right now. Its been a while since I played with QSPI here.

    Note that the scope QSPI decoder looks like its not set up correctly for decoding the opcode.

Reply
  • Reason is that the QSPI peripherial does not support anything other than some NOR flash chips that it is tailored for.

    Read the PS for details - you will likely need to change the design.

    Scope picture looks like a "read status" (RDSR) opcode to me. That one might be baked into either the hardware or the NRFX code - which one I am not sure right now. Its been a while since I played with QSPI here.

    Note that the scope QSPI decoder looks like its not set up correctly for decoding the opcode.

Children
Related