Code issue solutions in emWin_mcb1700_bsp

Showing results for 
Search instead for 
Did you mean: 

Code issue solutions in emWin_mcb1700_bsp

No ratings

Code issue solutions in emWin_mcb1700_bsp

1 Abstract

      MCB1700 is the evaluation board from KEIL, the onboard chip is LPC1758, LPC1768 or LPC1769 which is based on ARM cortex-M3.


      EmWin is the embedded graphics library developed by SEGGER, it is now offered by NXP in library form for free commercial use with NXP microcontrollers. The software bundle offered by NXP includes the emWin Color basic package, the Window Manager/Widgets module including the GUIBuilder, the Memory Devices module for flicker-free animation, the Antialiasing module for smooth display of curves, lines and fonts, the Font Converter and the VNC Server.

       NXP have provided the MCB1700 emWin board support packages:

emWin 5.14 BSP version 1.0 for MCB1700

 This package includes three IDE project: IAR, MDK and LPCXpresso, but now, when customer use it, normally will find these questions:

  • LPCXpresso project have the build error
  • MDK project have the build error
  • Some MCB1700 boards can’t work after downloading this code, LCD always display white, no other pictures.

    This document is mainly talking about these three problems and give the according solutions to make the MCB1700 emWin_mcb1700_bsp work.

2 Code issue analysis and solutions

     Customer need to download the emWin_mcb1700_bsp at first from the above link, and install it, after the package is installed in default, the source code can be found in this path: C:\nxp\emWin\NXP_emWin514_MCB1700_BSP

2.1 keil project build error

      This chapter mainly describe the emWin_mcb1700_bsp keil project build error and it’s solutions.

2.1.1 Problem reproduction

      Open the emWin_mcb1700_bsp keil project with keil IDE, you may find there has 6 errors like the following picture:


All these errors are related to the GUI function which is included in the emwin lib, after click the GUI folder, you will find the lib is emWin_514 which is the old emWin lib.


So people can try to use the newest lib from the nxp website.

2.1.2 Problem solution

    Download the newest emWin lib from this link:


emwin 5.30 Pre-Compiled Libraries for NXP ARM MCUs

   After install it, copy emWin_M3.lib from folder:

NXP_emWin530\emWin_library\Keil\ to NXP_emWin514_MCB1700_BSP\GUI folder.

Then add this new lib to the KEIL project’s GUI folder like this:


   After the emWin_M3.lib is added, remove the build of old lib emWin_514_Keil4_M3_LE.lib, just deselect item include in Target build in the right click options like this:


Save and rebuild it again, you will find the error is disappeared.


2.2 LPCXpresso project build error

    This chapter mainly describe the emWin_mcb1700_bsp LPCXpresso project build error and it’s solutions.

2.2.1 LPCXpresso project problem reproduction

Open LPCXpresso project, and build it, you may find these problems:


    All the errors are C/C++ Problem.

2.2.2 LPCXpresso project problem solution

    Choose project->properties, change the language standard to GNU C90 stand like this:


  Click button “ Apply”,  then rebuild it again, you will find the error is disappeared:


Of course, you also can change the lib to the newest one, just like the method in the KEIL project, use the newest LPCXpresso emWin lib from this folder:  NXP_emWin530\emWin_library\LPCXpresso\libemWin_M3.a


2.3 Code function problem in some MCB1700 board

     This part is mainly taking about the function problem in some MCB1700 boards, give the analysis and the according solutions.

2.3.1 Code function problem reproduction

      After the build problem is solved, customer can download the code to the MCB1700 board by debugger or programmer, no matter with LPC1758, LPC1768 or LPC1769. After testing some MCB1700 boards, we found some board always display white, the emwin function doesn’t work, but some board can display the correct picture. All these boards seems the same.

      I have compared these boards carefully, I found the series number in the LCD have difference, now I list it as follows:



LCD Series number







Abnormal, LCD display white



Abnormal, LCD display white



Abnormal, LCD display white

     From the above form, we can find all the MCB boards which can’t work have one feature: the LCD series number contains P120814, so it should be related to the LCD controller, but what the controller on these MCB1700 boards? After download the LCD_Blinky code from the KEIL IDE install path:


I found this project can display the picture correctly, so I do the debugging and the source code checking, after that I get the LCD with P120814 is using the HX8347-D LCD controller which from Himax company. But the LCD diver code in emWin MCB1700 BSP is for SPFD5408 LCD controller.


2.3.2 Code function problem solutions

    Here take MDK project as an example, describe how to modify the emWin_MCB1700_BSP code and make it work in those not working MCB1700 boards. After the analysis in the above chapter, you will get that the main problem is caused by the LCD driver, so the code modification is mainly about the LCDConf.c file, this code in this file is for the LCD driver configuration. Modify the display orientation

    Comment the old DISPLAY_ORIENTATION definition, and define it like this:


#define DISPLAY_ORIENTATION (GUI_MIRROR_X | GUI_SWAP_XY) Modify the LCD controller initialization code

From chapter 2.3.1, we can get the LCD on the not working MCB1700 board is HX8347-D, the HX8347 LCD controller initialization code should be modified like this:

static void _InitController(void) {

#ifndef WIN32





    /* Driving ability settings ------------------------------------*/

    wr_reg(0xEA, 0x00);       /* Power control internal used (1)    */

    wr_reg(0xEB, 0x20);       /* Power control internal used (2)    */

    wr_reg(0xEC, 0x0C);       /* Source control internal used (1)   */

    wr_reg(0xED, 0xC7);       /* Source control internal used (2)   */

    wr_reg(0xE8, 0x38);       /* Source output period Normal mode   */

    wr_reg(0xE9, 0x10);       /* Source output period Idle mode     */

    wr_reg(0xF1, 0x01);       /* RGB 18-bit interface ;0x0110       */

    wr_reg(0xF2, 0x10);      


    /* Adjust the Gamma Curve --------------------------------------*/

    wr_reg(0x40, 0x01);

    wr_reg(0x41, 0x00);

    wr_reg(0x42, 0x00);

    wr_reg(0x43, 0x10);

    wr_reg(0x44, 0x0E);

    wr_reg(0x45, 0x24);

    wr_reg(0x46, 0x04);

    wr_reg(0x47, 0x50);

    wr_reg(0x48, 0x02);

    wr_reg(0x49, 0x13);

    wr_reg(0x4A, 0x19);

    wr_reg(0x4B, 0x19);

    wr_reg(0x4C, 0x16);


    wr_reg(0x50, 0x1B);

    wr_reg(0x51, 0x31);

    wr_reg(0x52, 0x2F);

    wr_reg(0x53, 0x3F);

    wr_reg(0x54, 0x3F);

    wr_reg(0x55, 0x3E);

    wr_reg(0x56, 0x2F);

    wr_reg(0x57, 0x7B);

    wr_reg(0x58, 0x09);

    wr_reg(0x59, 0x06);

    wr_reg(0x5A, 0x06);

    wr_reg(0x5B, 0x0C);

    wr_reg(0x5C, 0x1D);

    wr_reg(0x5D, 0xCC);


    /* Power voltage setting ---------------------------------------*/

    wr_reg(0x1B, 0x1B);

    wr_reg(0x1A, 0x01);

    wr_reg(0x24, 0x2F);

    wr_reg(0x25, 0x57);

    wr_reg(0x23, 0x88);


    /* Power on setting --------------------------------------------*/

    wr_reg(0x18, 0x36);       /* Internal oscillator frequency adj  */

    wr_reg(0x19, 0x01);       /* Enable internal oscillator         */

    wr_reg(0x01, 0x00);       /* Normal mode, no scrool             */

    wr_reg(0x1F, 0x88);       /* Power control 6 - DDVDH Off        */


    wr_reg(0x1F, 0x82);       /* Power control 6 - Step-up: 3 x VCI */


    wr_reg(0x1F, 0x92);       /* Power control 6 - Step-up: On      */


    wr_reg(0x1F, 0xD2);       /* Power control 6 - VCOML active     */



    /* Color selection ---------------------------------------------*/

    wr_reg(0x17, 0x55);       /* RGB, System interface: 16 Bit/Pixel*/

    wr_reg(0x00, 0x00);       /* Scrolling off, no standby          */


    /* Interface config --------------------------------------------*/

    wr_reg(0x2F, 0x11);       /* LCD Drive: 1-line inversion        */

    wr_reg(0x31, 0x00);

    wr_reg(0x32, 0x00);       /* DPL=0, HSPL=0, VSPL=0, EPL=0       */


    /* Display on setting ------------------------------------------*/

    wr_reg(0x28, 0x38);       /* PT(0,0) active, VGL/VGL            */


    wr_reg(0x28, 0x3C);       /* Display active, VGL/VGL            */


//  wr_reg(0x16, 0x00);       /* Mem Access Control (MX/Y/V/L,BGR)  */


    /* Display scrolling settings ----------------------------------*/

    wr_reg(0x0E, 0x00);       /* TFA MSB                            */

    wr_reg(0x0F, 0x00);       /* TFA LSB                            */

    wr_reg(0x10, 320 >> 8);   /* VSA MSB                            */

    wr_reg(0x11, 320 & 0xFF); /* VSA LSB                            */

    wr_reg(0x12, 0x00);       /* BFA MSB                            */

    wr_reg(0x13, 0x00);       /* BFA LSB                            */


} Modify the LCD_X_Config configuration

   From the emWin display drivers website in the Segger:

You can find the HX8347 display driver is GUIDRV_FlexColor, the parameter pfFunc in function GUIDRV_FlexColor_SetFunc is GUIDRV_FLEXCOLOR_F66712.


  So, modify GUIDRV_FlexColor_SetFunc in the LCD_X_Config function like this:


    After the modification, then save and rebuild it. At last, download the code to the MCB1700 board which was not working before, download the code to the board, press the RESET button on the board, you will find the LCD displays the GRAPH_DATA_XY demo picture like this:


2.3.3 Other applications testing

   After the above code modification for the not working MCB1700 board, if you have interest, you also can try the other application to display other pictures. In folder  NXP_emWin514_MCB1700_BSP\Application, there still has a lot of other applications, you just need to add it to the application folder in the project, then the LCD can display the according picture,  now list some application’s testing result. GUI_WIDGET_GraphYtDemo.c

 pastedImage_13.png GUI_HelloWorld.c

 8.jpg GUI_ALPHA_TransparentDialogDemo.c

 pastedImage_15.png WM_RadialMenu.c


3 Conclusion

   From the above detail descriptions, you will know emWin_MCB1700_bsp KEIL project build error can be fixed by changing the lib to the newest emwin lib, LPCXpresso project build error can be fixed by changing the language standard to GNU C90, the function problem in some MCB1700 is mainly caused by the mismatch LCD driver, just modify the code to the according LCD driver can fix the LCD display white problem.

   Wish this document can help those customers who are using the emWin_MCB1700_bsp on the MCB1700 board, the modified project also in the attachment for your reference.

Labels (1)
Version history
Revision #:
1 of 1
Last update:
‎09-01-2016 03:15 AM
Updated by: