This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] MSPM33C321A: MSPM33 LVGL Solution

Part Number: MSPM33C321A
Other Parts Discussed in Thread: SYSCONFIG,

1. Background


Since the LP-MSPM33C321 features an onboard OLED display, you can display images and animations, such as in [FAQ] MSPM33C321A: How to play video 'bad apple' at LP-MSPM33C321A.
Furthermore, the M33 is capable of running LVGL (Light and Versatile Graphics Library), an open-source graphics library for embedded processors.
LVGL is integrated into the MSPM33 SDK*, allowing users to try it out-of-the-box.
We hope this FAQ helps users take their first steps in developing with LVGL.

Our LVGL demos in the SDK is based on LVGL version 8.3. 


2. Requirements

  • LP-MSPM33C321
  • MSP4031 or IPS Display 2 Click

  • CCS 20.5 (TI Clang v4.0.4, SysConfig 1.27)
  • MSPM33 SDK 1.03.0.01 (1.04 as well)

  • Example Project
    Target LCD Download link
    MSP4031 (ST7796, DFT6636U) here Floppy disk
    IPS Display 2 Click (ST7789V2) here Floppy disk
     

3. Quick Start Guide

In this section, we will walk through the setup for each display.

3.1 MSP4031 - 4 inch TFT Display

MSP403x is the 4 inch display with a ST7796 display driver, and MSP4031 supports TFT with DFT6636U capacitive touch driver as well.
Our example project in the SDK supports both of driver ICs.

Users can run the example project without any changes. For the detail of the setup, you can find it in the Readme and LVGL Use On MSPM33C.

  • C:\ti\mspm33_sdk_1_04_00_00\examples\nortos\LP_MSPM33C321A\demos\lvgl

If SDK version doesn't work well, especially TFT, please try attached above. In version 1.04.00,  SPI abstraction layer requires a small modification.


3.2 IPS Display 2 Click - 1.54 inch LCD with mikroBUS

LP-MSPM33C321 has a mikroBUS socket, so users can utilize various mikroBUS modules on the Launchpad.
IPS Display 2 Click is one of the LCD module with mikroBUS. Now you are free from complicated wiring (^ ^) 

The display has ST7789V2 display driver.
Unfortunately, we haven't supported ST7789V2 in the latest SDK yet. To port to ST7789V2, you have to modify lcd driver mainly.

Attached above, you can get the project for IPS Display 2 Click.

Modification steps by yourself

  1. Create empty project (nortos, ticlang).
  2. Duplicate LVDS folders in <SDK path>\examples\nortos\LP_MSPM33C321A\demos\lvgl to the project.
  3. Configure sysconfig along duplicated ti_msp_dl_config.c/.h. But I can't be bothered. Please copy the one in the attached project.
  4. Duplicate lcd.h/c, lcd_st7789.c, and lcd_st7796.c in the attached project to <project root>/lcd/. If you use other lcd drivers, please create the driver file by yourself.
  5. Change the display size and related parameters in <project root>/lcd/lcd.h.
    //LCD size
    #define LCD_Height 240
    #define LCD_Width 240


    And change the display size in <project root>/porting/lv_port_disp.c
    #ifndef MY_DISP_HOR_RES
        #define MY_DISP_HOR_RES    240
    #endif
    
    #ifndef MY_DISP_VER_RES
        #define MY_DISP_VER_RES    240
    #endif



  6. Change the SPI driver implementation for the defined functions in <project root>/lcd/lcd.c and <project root>/spi/spi.c.

Additional steps for IPS Display 2 Click

  • The RST port for mikroBUS socket is not connected on the LaunchPad. Actually, the RST port is pull-up on the module, so you don't care it. And, call software reset in LCD_Reset().
  • Set LV_COLOR_16_SWAP to 1 in <project root>/lv_conf.h.


With the changes above, you can run the LVDS demo.




4. FAQ

4.1 The build has not finished for a long time.

Probably it takes a while to complete the build in the first time. In my environment, it takes about 20 min.
If you wanna finish it earlier, you can change the optimization level to "-O0" in the complier option.
However, keep in mind that the optimization level directly results in the refresh rate.

4.2 How fast is the refresh rate?

You can fasten the refresh rate by adjusting some parameters.
Firstly, add GPIO output signal before and after disp_flush() to measure the rate with the logic analyzer. In the above attached project in section 3.2, the debug pin is already configured for PA26.

static void disp_flush(...)
{
    DL_GPIO_setPins(MEAS_PORT, MEAS_FLUSH_PIN);  // GPIO pin goes HIGH
    pending_disp_drv = disp_drv;
    lvgl_LCD_Color_Fill(...);
}

...

void lv_port_disp_flush_ready(void)
{
    lv_disp_flush_ready(pending_disp_drv);
    pending_disp_drv = NULL;
    DL_GPIO_clearPins(MEAS_PORT, MEAS_FLUSH_PIN);  // GPIO pin goes LOW
}


Then, you can see so many disp_flush() functions are called for each drawing process. The below waveform is for tab switching process in the demo widget project. It takes about 600ms.

Actually, it's difficult to get the general refresh rate because LVGL refreshes the only differential area of the display.
So I introduce here how to speed up the total duration of the tab-switching.

  • Optimization level
    this is the critical for the refresh rate. When I built with the optimization level 0, the process took 1s.
    As you upgrade the optimization of the executable, you can find that the duration of LOW between disp_function() get short.


  • Improve SPI clock
    It allows disp_flush() to run faster. For instance, transfer time is 4.60ms at 10MHz, and 2.29ms at 20MHz.

  • Improve CPU clock
    It allows to process graphic data faster.

  • Increase Buffer size
    This is not really important. While you increase the buffer size under the constrain of SRAM size, single disp_flush() function can update more pixels.
        /* Two buffers for DMA double-buffering (240x20 each = 9600 bytes each) */
        static lv_disp_draw_buf_t draw_buf_dsc_1;
        static lv_color_t buf_1[MY_DISP_HOR_RES * 20];
        static lv_color_t buf_2[MY_DISP_HOR_RES * 20];
        lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, buf_2, MY_DISP_HOR_RES * 20);


  • Shorten the render cycle
    In the default, it is set in 30ms, you can decrease the duration.
    /*Default display refresh period. LVG will redraw changed areas with this period time*/
    #define LV_DISP_DEF_REFR_PERIOD 10  /*[ms]*/

By the above adjustment, the processing duration become 480ms and the animation get smoothly.

Also, users can assess weighted refresh rate by lv_demo_benchmark().

Conditions Weighted Refresh Rate [fps]
80MHz CPU, 10MHz SPI, 30ms render cycles 16
80MHz CPU, 20MHz SPI, 30ms render cycles 29
80MHz CPU, 20MHz SPI, 10ms render cycles 34
112MHz CPU, 28MHz SPI, 10ms render cycles  52

4.3 How to display the Image with LVGL

You can display your image with LVGL, but you need to convert the image files to C array by the web tool.
Also I made the python script: download here. It works with Python 3.10+. For more information, please refer to the usage noted in the script.




5. Reference