tft display for stm32f4 free sample
STM32F429 has also LTDC driver for LCD like that, but this driver we will use later. For now we will use SPI for driving in serial mode and some other pins for controlling.
Remember: This library can also be used, if you are not using STM32F429 Discovery. It can be used in previous STM32F4 Discovery board. All pins can be changed in defines.h file which is included in project.
The LCD I am using is a 2.8″ TFT LCD with SPI communication. I also have another 16-bit Parallel TFT LCD but it will be another story for another time. For this post, let’s focus on how to display what you want on the 2.8″ LCD. You can find all details about this LCD from this page:http://www.lcdwiki.com/2.8inch_SPI_Module_ILI9341_SKU:MSP2807
First thing first, this LCD use SPI as the main communication protocol with your MCU. For STM32 users, HAL Library has already implemented this protocol which makes this project easier for us. But, a little knowledge about this protocol does not hurt anyone. SPI is short for Serial Peripheral Interface which, aside from two data lines, also has a clock line and select lines to choose between devices you want to communicate with.
This LCD uses ILI9341 as a single-chip SOC driver for a display with a resolution of 240×320. More details can be found in the official document of ILI9341. But the most important thing is that we have to establish astart sequencein order for this LCD to work. The “start sequence” includes many other sequences which are also defined in the datasheet. Each sequence starts when you send a command to ILI9341 and then some parameters to follow up. This sequence is applied for all communication between MCU and ILI9341.
For this project, I recommend using theSystem Workbench for STM32for coding and building the code. After installing and open the program, go to the source code you have just downloaded and double click the.cprojectfile. It will automatically be open in your IDE. Then build the program by right click on the folder you just open (TFTLCD) and chooseBuild Project. Wait for it to finish and upload it to the board by right clicking the folder, choose Run As and then clickAc6 STM32C/C++ Application. And that’s it for running the example.
The most important library for this project is obviously the ILI9341_Driver. This driver is built from the provided source code in the lcdwiki.com page. I only choose the part that we need to use the most in many applications like writing string, displaying image and drawing symbols. Another library from the wiki page is the TOUCH library. Most of the libraries I got from the Internet were not working properly due to some adjustments to the original one.
To draw symbols or even display images, we need a “byte array” of that image or symbol. As an illustration, to display an image from a game called Transistor, I have a “byte array” of that image stored in a file named transistor.h. You can find this file in the link below. Then, I draw each pixel from the image to the LCD by adding the code in the Display_Picture() function in the Display folder.void Display_Picture()
The above example is just only for displaying black and white image. In order to show a color image, we need to a little bit different. First, go tothis websiteto generate the array of the colour image. Remember to change your size to 320×240 and choose the 65K color option. Because it now takes up two bytes for one pixel, we need to send two bytes at once. You can check the Display_Color_Picture() function in the Display folder.void Display_Color_Picture()
As for the TOUCH feature, the way it works is that the screen will return the ADC value of the x or y coordinate of where you touch on the screen. The code I provided is a short version of the source code from the manufacturer and you can consider it as an extremely simple version of a touch screen feature. Because of that, the response time is very great. But for a simple application that doesn’t require drawing with your stylus, I think this works just fine. You just need to press on the screen long enough until it changes to a different layout.
Other than SPI pins, we need to select three more pins as output. I have selectedPB6 for CS, PC7 for RESET, and PA9 for DC. You are free to choose any other pins also, whatever suits the requirement
The resulting output will depend on the previous state of the output data register. - For the LOW data pins, the corresponding GPIO port bits in BSRR[31:16] need to be set to 1 in order to update all the 8-bit data bus lines at once.
I"m having a bit of trouble trying to get a small 320QVT TFT module up and running. The documentation available is quite vague, but I know the module used a SSD1289 TFT driver, and that 16 address pins are brought out on the module, as well as control lines. Although the module has an SD slot, and touchscreen ability, at the moment I"m just trying to get the display working.
I managed to find some documents which allegedly contains an initialisation and basic functions for the screen, which I have configured to run on the MCU I am using, which is an stm32f407VG (discovery board). But, unfortunately I"m still not able to get any control of the device. The thing lights up when powered on, but nothing else occurs.
1. I have found most examples are broken when used in later/modern versions of compilers for one reason or another (stm32 code pre 8 works but after 9 you will have cube lib issues ) and keil is just to variable between mcu"s and longer learning curve for some like me.
4. if you want to us STM then i suggest vscode platformio , it supports cubemx, arduino, cmsis and more, the reason i use it often is i can import sample code from many source libs type (cubemx,cmsis) into a fresh project easily and also use library"s easily (theres some trick to that but i can explain and demonstrate )
6. when starting out with stm32 it is worth having both platformio and stmcube mx /stm cube programmer installed, the reason is you can use the GUI of stm32 cubemx to configure your MCU/CPU and export that project, then with a few simple changes to a platformio.ini file you can have a instant populated project with peripherals configured , the cubemx IDE also has PDF"s and pinouts to the chips so i will often use it just for that and do the code in platformio , i use it because its got plugins that allow me to follow the code easier to the HAL_LL or hall low level and then i can create a bare metal version from there.
Now onto help to configure the FSMC, as mentioned you need GPIO, clocks, FSMC itself ,dma and irq"s with the latter two not fully required for initial function (and give no benefit in the start)
now you will note we have the above #define for the DATA portion of the LCD/FSMC , now just because we define it there does not mean we have configured the hardware fully,
_rs = PD12; // FSMC_A17 //Use PD11 for FSMC_A16 , rs is also known as REGISTER_SELECT and switches between command mode/data mode , when low mode is command mode
as to what MODER, OSPEEDR etc mean you can find that in the 407_vet manual available via cubemx or stm32 web site , but the short of them are they are the registers for each port (GPIOD,GPIOE etc) and the binary bits configure their operation. a example is
Seems interesting UGUI. However for example for the controller ST7586S have any examples of LCD functions to associate with UGUI? If you have made and canst send to me …
Vitor AquinoHi Vitor, sure it is possible to connect UGUI to the ST7586S. I will look for some sample code… Best regards AchimHello! I have recently been drawing Lissajous_curve through the Nios II, can I communicate with you?Email:maruixiang96@gmail.com
Thanks for the extensive library. I see you already used a ST7586S in one of your videos demonstrations. I have a similar display but it draws 2 pixel per byte and not 3 pixel as the datasheet . Can you help me with this ? below is the initialization code i used
Hi! Were you able to get 3 pixels per byte?Hi Andrey, yes! In order to use this feature you have to use a “read – modify – write” pset function which reads data from the display, changes it and writes it back to the display. BR Achim
Hi! I have the same problem with the pixels. Could you show me a example about the use of the "Read Modify Write" function to write 3 pixels per byte?. I did not understand this command on the datasheet. When this command is enabled, is it necessary to do the algorithm on the diagram at page 37 of the datasheet every time when i want write data to the display? Or is it only necessary one time on the initialization process?
We need to draw .BMP file while application is running. If you provide your mail id or whatsapp number I can share you more details about my requirements.. We are ready to pay for your services!! WA: +91 9787231007
I find this library somewhat intriging. Do you have any working Arduino examples, and if it is not asking too much – something for a SSD1322 based display?
Can you provide code for the dsPic33 with the SSD1322 driver? That is the exact setup I am trying to run for a project of mine. I am using the Blue Display. Thank you so much!!!!Hi Mike,
AchimAs we"re already talking Microchip, what would be necessary to get a Pic32MZ2048ECH144 and HX8238-A based display to use µGUI?First of all you have to connect the TFT DPI Interface to the PIC. Then initialize the internal DPI Interface of the PIC. After that you only have to write a Pset-function to use uGUI. Hope this helps! By the way: which hardware platform do you use? BR Achim
I really like the design of your code. I was able to get it up and running on a PSOC5 with no problems on a 128×64 newhaven display in so little time I was surprised!
Have you thought about how to implement screen rotation? I am wondering how to change to portrait from landscape on my display (at compile time, not run time)
I"m also interested in getting a 1.5" OLED SSD1351 running on a Raspberry Pi 2 Model B. In fact, I want to run 3 displays from that Pi (without exhausting the GPIO either–it"ll be running 3 sensors too).
At first i would like to congratulate you for this great library/project. I tested it in the STM32F429 Discovery and liked a lot. So, I would ask if you are interested in creating an adaptation layer for an event manager based on RTOS services. I beleive that through RTOS semaphores, queues and timers it is possible to better manage the CPU resources. I started myself a GUI event handler, as you can see here:
However, i´m not a great GUI designer. I just have a RTOS project and i would like to disseminate the use of such a great tool for embedded software development. Even, i developed a demo based in your code using RTOS services. Doing that i realized a excessive CPU usage for the touch screen reading (like 10%). I just raised the I2C clock to 250khz, droping the CPU usage for less than 1%.
First, I want to thank you for this library. I"ve used 0.2 version successfully with an OLED with SSD1322 controller on PIC32. Are the window and button functions work on OLED? I haven"t had success with the example code.Hi Andre,
Starting with your example of uGFX 3.0 on Stm32f429-Discovery (embd LCD removed) i have changed only screen dimensions to the ltdc.h in order to make it all work and so on it"s a really good result.
Can I use ugui with STM32F4-Discovery + ssd1963 fsmc module? I have ssd1963 library. I can run the screen but do not know how I could combine seamlessly with ugui. Can you help with this?Hi Mehmet,
Hi there i am after a oled display for a pure evoke flow radio and have been told it is a pmo 19301 and is 2.7" diagonaly my question is do you know where i can buy one of these units.
Nice job on the uGUI! I"m currently experimenting with it, I had an stm32f429 discovery board so could start right away with your example project in CoIDE.
I was wondering if I can use this library to get SSD1322 work with xmegaA3AU ? Can you help with some sample code, that would be great! Looking forward to your reply.
We are using Tiny6410 stamp module. It is restricted to using only friendlyarm display. We need to interface resistive touchscreen display of 5 inch & 7 inch of our choice. Please give steps how we can use your library.
Nice work! So impressive!I am new to OLED and now working a project using a NHD-3.12-25664UCB2 OLED with PIC, can u give me an pic code example with the SSD1322 driver? Thanks a lot in advance!Hi, have a look at the forum. There is an example Pset function for the SSD1322.
I tried, but I can not force to work my 240×128 display with T6963C controller . Could you please send me the code to this: 240×128 LCD | Driver: T6963C | Interface: 8080
I have a small display with no touchscreen. However I want to use windows with GUI buttons and use up/down buttons (physical buttons) to select GUI buttons on the screen (and use an enter button to simulate pressing a GUI button). Is it possible to do this with ugui, to select GUI buttons and generate GUI button clicks programmatically without toutchscreen?
Is there a sample project for STM32f7xx-Discovery also available?Hi, yes I’m going to write an example for the STM32F7. Unfortunately I’m very busy right now, so please be patient…
well, this is my first time using STM. i"m using stm32f407 by the way. i really want to use ugui with my stm and ssd1289. do you have any project example that i can use as refrence? it would be really helpful. thanks!Please have a look at the forum. Have you already downloaded my example projects? BR Achim
RegardsHi Ahmed, currently I don’t have any example for Codevision. Please have a look at my example projects. It should be quite easy to port them to your platform. BR Achim
Super nice library. It"s very well coded and easy to use. I"ve began developing on it a couple of days ago and will probably go with your library for the rest of my project.
thank you very much for the feedback! Good idea! There will be some more new acceleration functions available in 0.4…Please post your project at the forum!
KrzysztofHi Krzysztof, thanks for the feedback. I’m glad that you like ugui. Please post your source code on the forum. I will have a look at it. In general it should work! Best regards, AchimHi Achim,
hello. thanks for your good library . I want to use Farsi font . can you help me ?Hi there, if this is a TrueType font, a font converter is available on GitHub.
Hello, I am using your ugui. I use Psoc5 communicate with LCD TFT lil9341. Some funtion as UG DrawLine(), UG DrawArc()…run good on LCD. but some funtion about window not run on LCD. I dont understand about them. Examble funtion: UG WindowShow() {
Hello Achim Döbler, thank you very much for your library, how can i used your libary with st75256 controler ? do i need to write first the driver ? can you help me please about that ?
Just want to thank you for your effort and great framework that is easy to use but also very powerful. I am using it extensivly on STM32F429I-DISC1 board.
Hello, Thanks for the great library, i"am actually using uGUI to design my application. i just want ask you some question, the interface i am going to design is composed mainly with 3 parts :
My idea was to use an image to draw the battery level in the right corner, but here, i find that to use UG_ImageCreate i have to create a window at first and then attach the image, the library don"t provide a much easier function to draw an image in coordiantes (x,y), for me using windows is for managing dynamic things, things that are hidden and shown again in Runtime in fact I will use windows to manage tha main menu . I"am very interseted to know your opinion here
Hi, is there any library for driving SSD1322 based oled"s for STM32F4 or some sample code? I need it to drive one of those OLED"s for my custom PC project ;)
I have converted your uGUI Demo for the STM32F4 Discovery board using the 407 with LCD and Touch using the OpenSTM32 Workbench. If you are interested I can also post the source so that your uGUI tool can be easily used on this platform. Your Graphics library is clean, and easy to understand. Thank you for all your hard work.Dear Christian,
Which display to select? How to proceed with GUI programming using UGUI? I saw the reference guide but i"m totally new to this i"m getting extermely confused.
I am able to init the GLCD and able to run command All Pixel ON, All Pixel OFF. but when i am writing data to DDRAM i am not abl to get anything on the display could you please help.
sorry, but I don’t have the time to review your code right now. The only thing you need to do is to be able to toggle a single bit inside the display memory. After that the PSET-function will do the job.
However I noticed in the compilation that there were significant changes between the documentation and the v0.30 library in UGUI-master, to the point that the compilation after some adjustments in the example "uGui_STM32F429_Discovery" was running fine, and compilation with substitution by the files UGUI-master, have made so many mistakes that you want to be able to track.
Hi, I"m trying to setup an ST75256 based LCD display to a Raspberry Pi as 240×160 X-Windows active display. Is this possible and can you help me please?
Very nice project. I"ve got an OLED display with SSD1322 controller and I was wondering if I can use your uGUI library on my STM32F407 connected to the LCD via the 8080 parallel interface through the FSMC peripheral.
Thanks for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
Initially, an API specific to the LTDC implemented with a long-term objective of enhancing the generic display API to support more advanced LCD drivers either on-board or in-MCU while supporting smaller displays with little overhead. This driver should be modular; able to be built such that unused feature sets can be removed. The STM32 HAL will not be used (greenfield implementation). Existing generic display API will have shortcomings (e.g., pixel format support). Use shim to provide API implementation; native and generic APIs will be exclusive from each other.
OS/API-enforced constraints, e.g. Layer zero dimensions same as display, layer reordering limitations, maximum supported display size, limited number of display driver instances,
This tutorial shows you how to display string, color and dynamic value on LCD with STM32-Nucleo development board from ground up. It will also show you how to read the technical datasheet of LCD. If you are interested in more advance topic of RTOS from scratch, please go to Real-Time Operating Systems tutorial.
We want to display some string or color on the specific location of the LCD. We can achieve this by sending data to the specific address of RAM (Memory) in the LCD board. This is call Memory to Display Address Mapping. Take the image below for example. We want to make the top left corner of the LCD display a yellow square. First, you need to let the LCD knows at where of the RAM are you going to write the data to (using X_start, X_end, Y_start, Y_end value). Then you can start writing the data (color information) to those address of the RAM. Then, the specified portion of LCD will change it"s color according to the value you wirte into the address in the RAM. (Please refer to the ST7735s datasheet page 59 ~ 72)
In the following, we will first use CubeMX (link) to configure SPI and ADC (optional) on the STM32-Nucleo board and then generate code for keil µVision IDE v5 (link). Secondly, copy paste the code from the program we provided. Finally, we will test the code on the hardware.
Click File --> New Project --> In the search, key in your board model (STM32f411RE in our case) --> Click on the NUCLEO-F411RE --> Double click the item --> Click Yes to initialize all peripherals with their default Mode. --> Clear all Pinout.
You may wonder what pin of SPI should I use (you see we change the pin from the default PA5~7). Actually, ARM Cortex-M4 defined the combination of pins with SPI, I2C, UART. You can check the table from the STM32F411RE User Manual page 47 ~ 52. In the table, you can see we are using the combination of PB3/PB5, that combination also legit.
Before starting to display anything on the LCD, we need to initialize and configure the LCD by sending some command and parameters (data) to the LCD board. This initialization only need to be processed once. After that, we can send data to the LCD with correct protocol.
Let"s make the uper left corner of the LCD become green. In the following sending command as well as sending data, we all communicate via SPI. Remember that before sending data, we need to set the RS (Data or command) pin high. We set the RS pin low before sending command.
The reason of making this tutorial is that the code provided from instructor of the Udemy course is not working at all and the instructor didn"t reply to any student at all. I start from knowing nothing about SPI no need to say the LCD board. After 5 days of research, reading documentation, and trial and error, I finally make it works. This tutorial is to guide those people who want to get a deep knowledge of making a driver to display on LCD.
LVDS displays can vary a lot. LVDS displays are not governed by a set of well defined rules like MIPI DSI displays are. Therefore, it is up to the LCD manufacturer and the LVDS display driver IC manufacturer to use LVDS interface as they please, as long as they follow the physical interface and logic levels.
Based on this data, we can pick an LVDS transmitter IC. SN75LVDS84 from Texas Instruments is great for use with LCD displays that can be driven by an STM32.
A high-quality 3.5" TFT true-color display with a capacitive touch panel is the most distinctive feature of the mikromedia 3. The display has a resolution of 320 by 240 pixels, and it can display up to 16.7M of colors. The display module is controlled by the SSD1963 graphics driver IC from Solomon Systech. This is a powerful graphics coprocessor, equipped with 1215KB of frame buffer memory. It also includes some advanced features such as the hardware accelerated display rotation, display mirroring, hardware windowing, dynamic backlight control, programmable color and brightness control, and more.
The Power Supply Unit (PSU) provides a clean and regulated power, necessary for a proper operation of the mikromedia 3 development board. It is equipped with two different power supply inputs, offering all the flexibility that mikromedia 3 needs.
STMicroelectronics has delivered first samples of a new microcontroller family that combines today’s highest performing ARM Cortex-M4 core running at 180MHz and graphics-related enhancements, enabling richer user experiences. Simultaneously, ST is delivering increased software support for embedded graphics development in conjunction with leading vendor SEGGER.
The new 180MHz STM32F429/439 series extends the STM32 family’s performance lead among Cortex-M microcontrollers while new production and design techniques have reduced STOP-mode current, enabling longer battery life in portable applications. In addition, the STM32F429/39 has new features such as a TFT-LCD controller, ST Chrom-ART Accelerator™ for faster graphics, and SDRAM interface, allowing user interfaces for applications such as smart meters, small appliances and industrial and healthcare devices to provide richer, more colorful content and more intuitive operation.
I2S TDM (Inter-IC Sound Time Division Multiplex) connectivity allows multi-channel audio designs. Selected devices also have the latest, strongest anti-copying security for embedded processors.The new STemWin graphics software also announced today provides access to the SEGGER emWin embedded graphics stack, and is optimized to take full advantage of these new hardware graphics features.
STemWin is free of charge for STM32 customers, and also includes the SEGGER VNC Virtual Network Computing system enabling remote viewing of the user interface using Internet protocols. Additional powerful features for developers include window-manager and widget packages, touchscreen/mouse support, and memory device contexts that allow flicker free screen updates.
“Our STM32 series has established another important new benchmark with the arrival of the STM32F429/39 series,” said Michel Buffa, General Manager, Microcontroller Division, STMicroelectronics.” We are delighted, also, to complete our work with SEGGER to deliver STemWin for high-quality graphics development. The timing is perfect for our customers to take full advantage of the new STM32F429/39 features.”
“We are also entering full production with the STM32F427/437 series first revealed in November 2012,” continued Buffa. “These devices deliver high core performance and industry-leading memory density to support feature-rich apps and powerful software environments.”
The STM32F429/39 are now sampling to lead customers and are available in the established LQFP100, LQFP144, WLCSP, LQFP176 and UFBGA176 packages. In addition, ST has introduced two new package options with more than 200 pins - the LQFP208 and TFBGA216 packages that provide extra I/Os allowing designers to maximize the extra performance and functionality of these new devices.
Budgetary pricing is from $7.60 for the STM32F429VGT6 with 1MByte Flash and 256KByte SRAM in LQFP100 package, to $10.23 for the STM32F439BIT6 with 2MByte Flash, 256KByte RAM and crypto/Hash processor in LQFP208 package. All prices are for orders of 10,000 pieces per year.
The latest 180MHz version of the ARM Cortex-M4 core, featured in the STM32F429/39 series, allows customers currently using a microcontroller and discrete entry-level or mid-range DSP to replace or combine both chips in one digital signal controller based on a standard core. The combination also delivers high energy efficiency and access to the powerful development ecosystem supporting the STM32. The ARM Cortex-M4 core in ST’s STM32F4 variants is further enhanced with ST’s Adaptive Real-Time (ART) Accelerator. The ART Accelerator achieves zero-wait execution from Flash and achieves 225DMIPS (Dhrystone MIPS) and 606 Coremark (EEMBC Coremark benchmark) scores using industry-standard performance metrics.
By also providing designers with up to 2MByte Flash or 1MByte dual-bank Flash, each with 256KByte RAM - STM32F429/39 devices allow embedded systems to use sophisticated platforms such as Microsoft .NET, Java or uC Linux, whereas embedded designers have historically been limited to a structured language such as C. This approach enables developers to build more feature-rich applications, delivering enhanced user experiences, more quickly and efficiently. Devices with dual-bank Flash permit read-while-write operations which can help protect memory contents, for example by allowing an application to run normally while an update is downloaded to be applied safely at a later time.
In addition, ST has included support for high-speed SDRAM in the device by including an external memory interface for SDRAM modules, thereby offering a cost-effective alternative to SRAM external memories. This latest external memory interface also has a 32-bit wide data bus and operates up to 84MHz.
The enhanced display controller now provided on-chip allows the application to be connected to a standard TFT-LCD while benefiting from the low cost, physical size and real-time effectiveness of a microcontroller-based system. The on-chip TFT-LCD controller features ST’s Chrom-ART Accelerator, a hardware block for faster graphics processing, which is capable of doubling pixel-format conversion and transfer throughput compared to running software on the Cortex-M4 core. Developers can also take advantage of typical microcontroller on-chip features such as embedded reset capability and voltage regulators, as well as rich connectivity peripherals and integrated memories. The STM32F429/39 series also delivers freedom from high power consumption, external memory components and the non-deterministic behavior of an operating system, which are typical of MPU-based designs.
By providing state-of-the-art I2S TDM (Inter-IC Sound Time Division Multiplex) digital audio connectivity, the STM32F429/39 supports multi-channel audio designs, whereas earlier microcontrollers have typically supported only the dual-channel I2S standard.
Security and cryptographic capabilities are also enhanced. Whereas STM32F21x and STM32F41x series offered SHA-1 support as part of the hardware cryptographic and hash co-processor, the STM32F437 and STM32F439 now add SHA-2 support as well as AES GCM (AES Galois/Counter Mode) and CCM (Combined Cipher Machine). In addition, the STM32F439 offers advanced memory protection, allowing restricted execution-only access to Flash memory sectors. These new memory-protection features help software-IP providers, customers and silicon providers protect firmware against illegal copying.
Even with the increased core performance, the STM32F429/39 series has low current down to 100µA (typical) in STOP mode. This is around one-third the STOP current of the existing STM32 F2 and STM32 F4 devices, and is achieved through ST’s advanced 90nm fabrication process and new design techniques. Customers looking for both high-performance capability in RUN mode and low power in STOP mode now have a solution.
With the STM32F427/37 and STM32F429/39 families at the high end, ST’s STM32 microcontroller portfolio extends from entry-level STM32 F0 devices leveraging the Cortex-M0 32-bit core, through ultra low-power, mainstream and high-performance STM32 L1, F1 and F2 variants featuring the Cortex-M3 core, to the latest Cortex-M4 STM32 F3 and F4 mixed-signal and high-performance microcontrollers with DSP and Floating-Point Unit (FPU). All benefit from ST’s low-power process technology.
Extensive pin, software and peripheral compatibility among STM32 microcontrollers, and the extensive supporting ecosystem including code samples, design IP, low-cost Discovery kits and third-party development tools, enhance flexibility to scale designs, re-use software and hardware and gain the maximum benefit from investing in the STM32 platform.