LPC54S018 rotate display to portrait failed with lvgl

Description : Rotate TFT display to portrait failed with lvgl
What MCU/Processor/Board and compiler are you using : LPC54S018 , MCUxpresso V11.4.4 , SDK 2.xLPC54018 2.10.0 , 800 x 480 landscape FTF display .
What LVGL version are you using : lvgl 7.10.1

What have you tried so far : used the" rotated" parameter and set to 1.
“sw_rotate” parameter not found in the demo project "lpcxpresso54s018littevgl_demo_widgets_bm " .

Code to reproduce /

driver->flush_cb = NULL;
driver->hor_res = LV_HOR_RES_MAX;
driver->ver_res = LV_VER_RES_MAX;
driver->buffer = NULL;
driver->rotated = 1;//0
driver->color_chroma_key = LV_COLOR_TRANSP;
driver->dpi = LV_DPI;

Screenshot and/or video

parameter rotated set to 0

parameter rotated set to 1

Witg regards

Hi, you set the fluch_cb to NULL and it works?!
I use v8.1 and it works for me fine.

After this initialisation , flush_cb is set to :

disp_drv.flush_cb = DEMO_FlushDisplay;


So, It’s better to put all your init codes.
Here is mine, hope it can help you:


	static lv_disp_draw_buf_t disp_buf;
	lv_disp_draw_buf_init(&disp_buf, lvgl_buf, NULL, 1280 * 44U) ;    /*Initialize the display buffer*/

	lv_disp_drv_init(&disp_drv);          /*Basic initialization*/
	disp_drv.hor_res = hor_res_max;               /*Set the horizontal resolution*/
	disp_drv.ver_res = ver_res_max;               /*Set the vertical resolution*/
	disp_drv.flush_cb = ex_disp_flush;    /*Set your driver function*/
	disp_drv.draw_buf = &disp_buf;          /*Assign the buffer to the display*/
	disp_drv.antialiasing = 1;
	disp_drv.sw_rotate = 1;
	disp_drv.rotated = LV_DISP_ROT_NONE;
	disp_drv.full_refresh = 1;
	lv_disp_drv_register(&disp_drv);/*Finally register the driver*/

You will need at least LVGL 7.11.0 to use software rotation (otherwise the driver needs to have special logic to handle it). I’d suggest using the release/v7 branch on GitHub, as the 7.11.0 release had some bugs which have been fixed since then, and we don’t officially support anything older than the release branch for the previous major version.

I updated to V7.11.0 .

Now, I can set
driver ->sw_rotate = 0;
driver->rotated = LV_DISP_ROT_NONE;

On the TFT display protrait on a landscape vieuw

When I set
driver ->sw_rotate = 1;

driver->rotated = LV_DISP_ROT_90;

The TFT is completely black
With regards

Hello Gabor,

I updated the lvgl 7.10.1 to lvgl 7.11.0 .
Now i see the

driver->rotated = LV_DISP_ROT_NONE;
driver->sw_rotate = 0;

When I use these settings , the portrait appears om the landscape view.

driver->rotated = LV_DISP_ROT_90;
driver->sw_rotate = 1;

a black sreen appears , no rotation

in the function
void _lv_disp_refr_task(lv_task_t * task)

lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);

            /*Flush the content of the VDB*/

            /* With true double buffering the flushing should be only the address change of the
             * current frame buffer. Wait until the address change is ready and copy the changed
             * content to the other frame buffer (new active VDB) to keep the buffers synchronized*/

uP stays in while(vdb->flushing)

Usually it happens if lv_disp_flush_ready() is not called. Please be sure it’s called in the rotated case too.

I updated lvgl to version 7.11.0

parameter rotated = 1 and sw_rotate is now visible , set to 1.
I changed nothing in the source files of lvgl . lv_disp_flush_ready() is executed

Hello Gabor ,
At this moment , i use the lvgl features to rotate the image to portrait .
Any suggestions to let this rotate work ?

Hello Gabor,

When the display is in landscape , lv_disp_flush_ready() is excecuted after



portrait screen in landscape view.

When driver->sw_rotate = 1; and driver-> rotate = LV_DISP_ROT_90;
lv_refr_vdb_flush(); is called

while(vdb->flushing) keep in this while routine and display is black.

lv_refr_vdb_flush(); is not called because the flushing gives a problem.

Any idea where to look after ?

With regards

Hello Gabor ,

We tested with version8 , still no working rotation in portrait.

We had contact with nxp:

Feedback NXP support :

We checked this new feature for different platforms (rt500, RT1060, lpc54s018) and found that it works for some of them and not for others. The implementation is the same in all the devices, and it is not different in the driver, so we are not sure what’s going on. As this is a new LVGL feature, we are discussing with them possible causes.

At this moment , we are about 6 weeks further and have no solution received from LVGL.

With regards


It great that you updated to v8.

Please copy how you initialize the display driver, display draw buffers and the flush_cb.

I corner case just came to my mind that can cause the issue here too. Do you have disp_drv.full_refresh = 1;?

Hi Gabor,

Hi hope that yo are doing well!

I am testing with my i.MX RT1064 and i.MX RT1060 and I ended up with a black screen like @Paul_B mentioned. Interestingly my customer , who is using an RT1064 got a irregular line red, white and gray.

I have used the _lvgl_guider and the lvgl_demo_widgets_bm examples from the latest NXP MCUXpresso SDK. The version of the LVGL is 8.0.2.

Please find my init function attached.
init_driver_func.c (1.2 KB)

disp_drv.full_refresh = 1; is set to one.

According to my debug, in my case there is a problem when doing display rotation. See the image.

So it seems that we could modify some code.

Let me know your thoughts.

Best regards,

Hi @kisvegabor
I was able to perform 180 degree rotation (rotated = 2 ) with hardcode, although the display refreshing does not look good and touch is not okay . I am using lvgl_demo_widgets_bm demo.

Not the best, but there is seems that there is proper stuff do.

270 and 90 do not work, that is rotated =2 and rotated= 3

Best regards, Diego


If you disable the full_refresh flag, probably the flush_cb needs to be modified as well.

I believe now the flush_cb only set a new frame buffer for the LCD periphery. But with full_refresh = 0 LVGL will only draw only the changed area so the simple address swapping won’t work.

Instead there should be a frame_buffer permanently set for LCD periphery and the flush_cb should copy the refreshed areas to that frame buffer.

See here as an example: https://github.com/lvgl/lv_drivers/blob/1bd4368e71df5cafd68d1ad0a37ce0f92b8f6b88/sdl/sdl.c#L188-L192

Hello Gabor,

The FAE of EBV have tested the earlier changes.
Last Friday , I uploaded mcuxpresso V11.5 with SDK2.11 for LPC54S018 .
I have some problems with the OM40003 (not possible to erase the flash with GUI Flash Tool , even with ISP0 button pudhed-in) . Can also not debug with the OM40003.
First I must solve this problem before I can test .

With regards

Hi Paul,
If you are still going with this issue ( or appears frequently) :
When the MCU is set into ISP mode, try to do an erase using ROM bootloader. This easily done with the Flash Magic Tool ( Download - Flash Magic ). They are NXP partners. If use tool to regain debug access quickly.

If you get any positive results to rotate the image, please share.


Hello Diego,

Yes, this issue is solved.

With reagards

Hello Gabor,

I found in the evaluation software of NXP for the LPC54S018 the following:


  • Rotate the draw_buf to the display’s native orientation.
    static void draw_buf_rotate(lv_area_t *area, lv_color_t *color_p) {
    lv_disp_drv_t * drv = disp_refr->driver;
    if(disp_refr->driver->full_refresh && drv->sw_rotate) {
    LV_LOG_ERROR(“cannot rotate a full refreshed display!”);

This is a restriction in there sofware or lvgl ?

With regards