Thank you for your response.
Looking at the datasheet for REG_SPI_WIDTH Definition:
Bit 2: Extra dummy on SPI read transfer. Writing 1 to enable one extra dummy byte on SPI read transfer.
Bit 1 - 0: SPI data bus width: 0b'10: 4 bit (Quad-SPI)
I would need to send: 00000110 (0x06)
Correct?
In the FT9xx code, it looks like '4' is being sent:
// Turn on FT9xx quad-SPI.
spi_option(SPIM, spi_option_bus_width, 4);
The reason I ask is because in the Programming Guide (page 12) for Quad SPI, it says when reading, you have to send:
WR/Address -> Address -> Address -> Dummy -> Data -> Data...
Trying to wrap my head around this, I set REG_SPI_WIDTH, TFT_write8(REG_SPI_WIDTH, 6);
This should switch into Quad SPI mode, correct? I then immediately try to read the REG_SPI_WIDTH out to make sure I can successfully read something, kind of like initially reading the Chip_ID:
uint8_t TFT_read8(uint32_t const address)
{
QSPI_CommandTypeDef sCommand = {0};
// Set up the command structure
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; // Instruction sent over 1 line
sCommand.Instruction = (uint8_t)(address >> 16U); //Get the first byte, should look like 0x30
sCommand.AddressMode = QSPI_ADDRESS_1_LINE; // Address sent over 1 line
sCommand.AddressSize = QSPI_ADDRESS_16_BITS; // Try using 16-bit address
sCommand.Address = address & 0xFFFF; // Mask off the first byte and keep the last two bytes
sCommand.DataMode = QSPI_DATA_1_LINE; // Data mode for receiving ID
sCommand.NbData = 2; // Expecting 2 bytes (for ID)
sCommand.DummyCycles = 0; // No dummy cycles
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; // Disable DDR mode
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; // Send instruction every command
// Send the command (instruction and address)
if (HAL_QSPI_Command(&hqspi, &sCommand, HAL_QSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
Error_Handler();
// Now receive the data
uint8_t retData[2] = {0}; // Array to hold the received ID
if (HAL_QSPI_Receive(&hqspi, retData, HAL_QSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
Error_Handler();
uint8_t data = retData[1];
return data;
}
This however does not work, it either hangs waiting for a response or ends up in the Error_Handler(). I think I have what needs to be sent correct. Referencing the Programming Guide:
4.1.3 Host Memory Read
For SPI memory read transactions, the host sends two zero bits, followed by the 22-bit address. This is
followed by a dummy byte. After the dummy byte, the BT817/8 responds to each host byte with read
data bytes.
Do you see anything obvious that I have wrong?
Kindest regards.