UART stands for “Universal Asynchronous Receiver / Transmitter”, and it is a very simple serial communication interface. It is such a fundamental peripheral that I vaguely thought I’d already written about it until I got a couple of comments asking about it, so thank you for those reminders! Usually when people write microcontroller tutorials, UART is one of the first peripherals that they talk about, and I’ve gone far too long without mentioning it. If you’ve been reading the posts about STM32s that I’ve been writing, I owe you an apology. It also includes 64MB of memory-mapped QSPI Flash memory, which I’ll talk about in a future post.
It is a bit more expensive than the minimal “Nucleo” boards, but it includes 512KB of external RAM and a 240×240-pixel TFT display we’ll learn how to drive both of those from the FMC peripheral in this post. So the target hardware for this tutorial will be a $40 STM32F723E Discovery Kit. This is especially hard on hobbyists, because 2-layer boards are not appropriate for these sorts of designs and KiCAD does not support length-matching for more than two traces yet. The interfaces use a lot of signals which are susceptible to electromagnetic noise, so it is important to ensure that all of the traces have the same length and impedance. Unfortunately, it is not easy to design a custom PCB with parallel memory modules. Developers have gotten used to having enormous reserves of memory to draw from, so unless an application or library was specifically written for embedded platforms, it probably won’t be able to run with the scant kilobytes of RAM which are included in your average microcontroller.įortunately, most vendors include peripherals for accessing external memory when it is needed, and the STM32’s “Flexible Memory Controller” is surprisingly easy to use.
But software complexity has also grown over time, and as we humans often say about ourselves as we age, it has grown in the wrong direction. They are much faster and cheaper than the sort of processors that powered “real” computers a few decades ago, and they’re also very power-efficient. So if you want to learn how to use Quad-SPI Flash memories with an STM32, read on! And writing to Flash memory has some unique limitations anyways, which is why it is often used to store data which an application rarely needs to modify, like firmware or audio/visual resources. It is a little bit annoying that you can’t write to the Flash chip in memory-mapped mode, but this peripheral still presents a simple way to quickly read from external Flash using only six I/O pins.
If you don’t like copy/pasting, you can find an example project with this code on GitHub. Then we’ll set the QSPI peripheral to its read-only “memory-mapped” mode, and read those test values by accessing the chip’s internal memory space starting at 0x90000000. In this post, we’ll learn how to configure the Flash chip for quad I/O access, erase a sector, and write some test values. In addition to its external RAM and display, this board includes one 64MB QSPI Flash chip connected to the QSPI peripheral.
To learn about the QSPI peripheral, I used the same STM32F723E Discovery Kit from my last post about external memories.
The peripheral supports prefetching, caching, executing code, and it can even access two QSPI Flash chips in parallel, using 8 data lines in total to transfer a full byte of data every clock cycle. You can use it to manually configure / erase / program the Flash chip, and once it’s initialized, you can also map the external Flash as read-only memory in the STM32’s internal memory space. Some STM32 chips include a QSPI peripheral to interface with these kinds of Flash memory chips. That’s because many 8-pin Flash chips also support a “Quad-SPI” interface, which is very similar to a bidirectional “3-wire” SPI interface, except that it has four I/O wires instead of one. But if you look in the image above, you’ll see that the /WP “Write Protect” and /HOLD or /RESET wires are also marked as IO2 and IO3. They usually use a SPI interface for communication, with a couple of extra pins for functions like write protection or suspending an ongoing transaction. You can get RAM, Flash, EEPROM, and even FRAM memory in these common 8-pin packages. Pin assignments for a generic Flash module ( Winbond W25Q series)