1. Product Selection Guide

    parametric search on NXP.com
  2. Videos

    This text will be replaced

  1. Adding an LCD to your microcontroller application made easy, inexpensive & fun!

    LPCnow (Feb 13 2013)

    1. Adding an LCD to your microcontroller application made easy, inexpensive & fun!

      With today’s low prices of touch screen color LCD displays and high performance 32-bit microcontrollers, it becomes more and more attractive to add a touch-screen interface to your application. Touch screens are a great way to provide an intuitive and appealing Graphical User Interface (GUI).

      This blog shows how easy it is to create a good looking GUI using any NXP ARM-based microcontroller together with Segger’s emWin graphical library, and in particular it will focus on the element14 board with the NXP LPC4357 microcontroller. Though emWin is a commercial product and requires a paid license in order to use it, it may be used for free on any NXP ARM microcontroller, unrestricted and even for commercial purposes! NXP has already licensed emWin, and therefore NXP customers may use the emWin library for free on ARM-based NXP microcontrollers.

      What used to be so difficult when developing a GUI?

      If you have ever tried it yourself, you’ll know how hard it is to develop a GUI and the required framework on an embedded platform.  To do it properly, you’ll need to develop many basic functions to manipulate pixels, draw lines, squares, circles, text, images and so on. More advanced functions combine these basic functions, allowing you to draw objects like buttons, sliders radio buttons, … Code must be written to read out the touch screen and handle touch screen interaction. After all that work, you’ll only have a bunch of functions for a very basic GUI. As you’re targeting an embedded platform, you’ve got to optimize your code to get decent performance and a decent size of your binary. Long story short: creating your own graphical framework takes a lot of effort!

      emWin as solution

      But, things have changed and luckily nowadays there are a number of software libraries (both commercial and open source) available which already integrates this complex framework. One of the best examples of these libraries is emWin. It has many cool features like a large collection of widgets (e.g. buttons, sliders, check boxes and advanced widgets for creating nice menus), support for Anti Aliasing, touch screen support, a window manager taking care of multiple layers, and it has even much, much more features. Still it achieves a great performance on relatively simple CPUs like the ARM Cortex-M series.

       Figure 1. Example of the Radial Menu widget of emWin. The selected menu item can be changed by swiping the screen

      emWin on NXP microcontrollers

      As said before, NXP has licensed Segger’s emWin so that you can use it for free on any NXP ARM based microcontroller. There is quite some material out there (e.g. http://www.lpcware.com/content/project/emwin-graphics-library) to get you started. The easiest way is to get any of the supported development boards, download the accompanying Board Support Package (BSP), hit compile and download in right into your board. Thanks to the documentation available, for example a porting guide on how to port the BSP to your own hardware, it’s easy to use it on any of your favorite (custom) NXP ARM based MCU board. Examples are available showing emWin on LCDs without onboard controller, therefore utilizing the NXP LCD controller peripheral. There are also examples available showing how to use emWin together with LCDs with onboard controller, connected to the SPI bus of an MCU.

      The Element14 LPC4357 board

      One board that has just been released by Element14 (Farnell) features the NXP LPC4357 (dual-core ARM Cortex M4/M0) MCU. The board is being sold as a Dual Core Multimedia Eval Board and is described as a “High-performance, low-cost solution for developing DSP and MCU applications”. It has many great features, like the LPC4357 MCU with 1MB of FLASH, onboard 256Mb QSPI flash memory, audio, USB and an optional 4” 480*272 LCD. Considering the price being just under €90 (including the LCD), it’s quite a good deal!

      emWin on the E14 board

      One of the examples provided by element14 is a full emWin BSP. It has been configured to run through a large number of GUI examples, showing off the capabilities of emWin. At first sight the performance is somewhat disappointing considering the specs of the MCU. This was all explained while looking in more detail at the project configuration; the BSP is configured to fully execute from external memory. After tweaking the linker settings in Keil µVision to execute code from internal FLASH, the real performance of the LPC4375 was revealed!

      Figure 2. The LPC4357 Dual Core Multimedia Eval Board with LCD module

      Designing your own GUI & loading it into the board

      Designing your own GUI when using emWin is easy. emWin comes with a GUIBuilder tool, which let you graphically develop your GUI on a windows host PC, similar to developing a PC application in e.g. Visual Studio. Widgets can be dragged and dropped onto a window. After building your GUI, the tool converts it into a .c file which can then be added to your project.

       Figure 3. The GUIBuilder tool in action

      After creating your GUI, it’s time to add it to the BSP. The first step is to remove the existing demo GUIs, by simply removing all .c files from the Keil project that begin with “GUIDEMO”. Next, the .c file from the GUIBuilder tool (FramewinDLG.c) must be added to the project, and the emWin entry function must be added to the FramewinDLG.c file:

      void MainTask(void) {
        CreateFramewin() ;
        while(1) {
          GUI_Delay(500) ;

      Now simply recompile, flash the new binary into the board and feel proud of running your own GUI on the board! As a next step, you can apply skinning, as described in this blog, to finish it up nicely.


      Figure 4. GUI developed in the GUIBuilder alive on the LPC4357-EVB

      Bookmark or Share this article