SPI - GC9A01A LCD Screen
0. Connection
3V3
VIN
5V or 3V3 power supply
GND
GND
Ground
PA5
SCL
SPI 1 SCLK
PA7
SDA
SPI 1 MOSI
PA9
RES
IC Reset N
PA8
DC
Data / Command select
PB6
CS
SPI 1 Chip Select N
PC7
BLK
Backlight enable
1. Configure STM32
In the left sidebar, select Connectivity -> SPI1.
Select Mode to "Transmit Only Master".
Select Hardware NSS Signal to "Disable".
Set SPI Mode to MODE0
Set Clock Parameters -> Prescaler to 2. The chip can run up to 40 Mbits/s.

2. Code
The code is adapted from Adafruit library
One tricky think is the SPI_WRITE16 function. The byte order is easy to mess up.
In STM, when passing the uint16_t value to the transmit function, the lower byte in the memory address is transmitted first. However, we want to maintain the byte order, and thus we need to swap the uint16_t btyes before we invoke the transmission function.
3. Result
After connecting an RFID-RC522 SPI module, we can see that we can read the register from the sensor. The SPI signal looks like this:

https://community.st.com/s/question/0D53W00001nAhvYSAS/how-to-use-spi-nss-on-stm32g0
Last updated
Was this helpful?