|
F439_CPP_SPI_RA8875_TFT_LCD_04 1.0
STM32F439 SPI RA8875 7-inch TFT display with FRAM-backed touch calibration, built on the STM32_GFX, STM32_RA8875 and STM32_MB85RS64V libraries
|
This documentation covers a STM32 NUCLEO-F439ZI tutorial project that drives Adafruit's RA8875 driver board and 7-inch 800x480 TFT display over SPI, reads its resistive touch panel, and keeps the touch calibration in an MB85RS64V SPI FRAM so it survives a power cycle. It builds on three reusable STM32 HAL libraries: STM32_GFX (a port of Adafruit GFX), STM32_RA8875 (a port of Adafruit_RA8875) and STM32_MB85RS64V (an FRAM driver). It is the fourth part of the RA8875 series; part 3 introduced the two display libraries.
The firmware demonstrates:
main.c through C-callable functions declared in entryPointCPP.hppextern "C" entry points called from main.cTested on a breadboard with a NUCLEO-F439ZI:
| Signal | NUCLEO-F439ZI | Notes |
|---|---|---|
| SCK (display and FRAM) | PA5 | SPI1_SCK, shared |
| MISO (display and FRAM) | PA6 | SPI1_MISO, shared |
| MOSI (display and FRAM) | PA7 | SPI1_MOSI, shared |
| RA8875 CS | PB6 | GPIO output, label RA8875_CS, initial level high, pull-up |
| RA8875 Rst | PC7 | GPIO output, label LCD_RESET |
| MB85RS64V CS | PB10 | GPIO output, label MB85RS64_CS, initial level high, pull-up |
| MB85RS64V VCC | +5V | The chip takes 3.0 to 5.5 V. See the note below the table about its input levels |
| MB85RS64V GND | GND | |
| MB85RS64V HOLD | VCC (+5V) | Active low: a low level pauses the chip, so it will not answer |
| MB85RS64V WP | VCC (+5V) | Active low: only protects the status register; keep high so it stays writable |
| Debug console | PA9 (TX) / PA10 (RX) | USART1, 19200 baud |
The FRAM is powered from +5V here. Its high input level is 0.8 x VDD, which is 4.0 V at 5 V, while the STM32 drives its outputs to 3.3 V, so SCK, MOSI and CS are below the datasheet's input level. It works on this breadboard, but powering the chip from 3.3 V instead puts those signals inside the specification.
The RA8875 board's Wait, Int, LITE and 3Vo pins are not connected.
Do not connect 3Vo. It is an output: the 3.3 V that the board's own regulator produces. It is not a power input, so never wire it to VCC, to the NUCLEO's 3.3 V pin or to any other supply rail. The board is powered from Vin (+5V, see part 3).
See the MB85RS64V class documentation for why HOLD and WP must be high. The display's touch panel is wired through the display board; it needs no extra connections.
Debug output goes to a USB-to-serial adapter on USART1 at 19200 baud: printf() is redirected there by the pre-build scripts. The same terminal is used to answer the calibration prompts, so it must be able to send keys.
TOUCH_CALIBRATION_ENABLE is defined in main.h, testTouch runs the interactive calibration regardless of what the FRAM holds, stores the result, runs a 15-second touch-to-draw demo, prints "Calibration Complete" and stops. With the macro commented out, none of that code is built and the program runs the graphics and text demos from part 3.The RA8875 library writes the matrix itself: seven big-endian 32-bit values plus a "calibrated" flag byte, 29 bytes at FRAM address 0x0100. This project adds a 12-byte header at 0x0120 holding the marker "CAL1", a format version, the length, and a CRC-32 of the matrix block. The matrix is written first and the header last, so a power cut in between leaves a header that does not match and the half-written data is never used. After writing, the data is read back and compared. Loading checks the marker, version, length, checksum, the library's flag and that the divider is not zero.
TOUCH_CALIBRATION_ENABLE defined, every boot recalibrates and replaces the stored calibration.stm32-cubeide-scripts pre-build step edits main.c and main.h on each build (the printf redirect, the error handler and full assert). The libraries are git submodules; clone with git clone --recurse-submodules.