2025-09-23 12:51 AM - last edited on 2025-10-08 6:41 AM by Amel NASRI
Hello Community,
I've been trying without success to setup an SPI interface to a LCD panel. It's an LTDC 24-bit panel but requires configuration over its 3-wire SPI interface. I'm using STM32CubeMX 6.15.0 and STM32CubeIDE 1.19.0. Here's the details:
The display contains an ST7701S IC that has a 9-bit, half duplex, SPI interface, operating mode RGB+9b SPI(rise). In this mode the display accepts 9-bit data - the MSB bit (8) indicates whether the following byte is a command or data. I can issue commands to the display and have it do things (turn all pixels ON/OFF as an example) but I'm unable to successfully read from the device. A read is initiated by transmitting a read command and then reading the response over SPI.
The display is connected as follows:
and I have configured it in CubeMX as follows (Note CS and RESET are configured as GPIO outputs).
The timing diagram in the ST7701S datasheet looks like this :
This display is using Interface 1 as I understand it. So I should be able to do a 9-bit transmit and then read the response. I cannot get this to work with this simple code:
uint8_t cmd = 0x0A;
uint16_t rx_data = 0;
uint16_t tx_data = (0 << 8) | cmd; // D/CX = 0 for commands
ST7701S_CS_LOW();
HAL_SPI_Transmit(&hspi1, (uint8_t*)(&tx_data), 1, HAL_MAX_DELAY);
HAL_SPI_Receive(&hspi1,(uint8_t*)(&rx_data), 1, HAL_MAX_DELAY);
ST7701S_CS_HIGH();
where the CS macros are defined as:
#define ST7701S_CS_LOW() HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET)
#define ST7701S_CS_HIGH() HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_SET)
I know that the HAL receive function is toggling bit 11 (HDDIR) in the SPI_CR1 to control direction on the half-duplex line. (Section 6.8.3 of RM0456).
I have attached the output from a scope which is showing the SCK on the top input and the MOSI line on the lower input. You can see there's no data on the lower input.
Anyway, this is a lot to take in and I appreciate it's complicated so any help would be much appreciated.
DD