Drawing area error when using spi dma transmit and keypad?

It is OK when using spi trans without DMA.
When I want to use DMA to transmit data, the first frame looks perfect, but when I hit keypad the frame goes wrong. It seems there is a displacement on the screen.

static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
uint16_t data_size = (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1) * 2;
if ( HAL_SPI_Transmit_DMA(&hspi3, (uint8_t *)color_p, data_size) != HAL_OK)
{
}
}
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)
{
lv_disp_flush_ready(&disp_drv);
}

Is anyone had used stm32 spi dma to flush data in lvgl? Thanks~

init%20frame

this is power up, looks just fine.

But when I hit kaypad ENTER.
It looks like this:

test

And this happned when hit kaypad PREVIOUS:
keypad%20NEXT

I suppose you have a display controller where you should set the window to draw (col and row addresses) but I can’t see it in disp_flush.

Take a look at this:

Thanks~ That helps a lot.
But one more thing please.:smiley:

when I try benchmark or sysmon everything seems OK.
But when I try to use spi dma mode in Demo or lv_tutorial_themes , buttons are not responsive, and the sreen seems flush only a little part of the frame.

I opensourced my project on github, under branch of baremental. It is under development right now.

Thanks @kisvegabor.

This is the test case of benchmark using spi dma.
The speed is nearly twice compared to tranmit directly with spi.(48ms wo spi dma).

I thought everything was just fine before I tried demo with dma again…(as you can see above)

Glad to hear that you make it work!
Could you write a few lines about your project in the My projects category?

If are interested you can even write a blog post about it. :wink:

Of course.
But I am trying to fix the bug.It is not really work properly.
As you can see in the picture, the demo is not working it supposed to be.

Oh, sorry, I misunderstood it.

It"s very strange that some examples are working and others are not depending on the use of DMA.

What if you enable LV_DEMO_SLIDE_SHOW?

Can you enable logging and print log messages? You should use LV_LOG_LEVEL_TRACE.

Please ensure that the MCU is still running. No hard fault or infinite cycle.

I suspect the problem is caused by driver.
when setting drawing area I am using HAL_SPI_Transmit(&hspi3,data,size,1000);
But when transmitting picture data I am using HAL_SPI_Transmit_DMA(&hspi3, (uint8_t *)p, (x_end - x + 1) * (y_end - y + 1) * 2).

I am not sure if this would cause the problem.
I will try to fix it later on.

Thank for your suggestion.

By the way, do you know AliOS-Things merged your lvgl into their solution?
Alibaba is a giant in World. The OS has a influence in IOT world. Maybe you can give them some advices about lvgl.

As far as I known, their demos flush image data without DMA?

Could it be an upper limit in DMA transfer size? I suggest trying with LV_HOR_RES_MAX*2 buffer size. Maybe we will see something which helps to find the issue.

By the way, do you know AliOS-Things merged your lvgl into their solution?
Alibaba is a giant in World. The OS has a influence in IOT world. Maybe you can give them some advices about lvgl.

No, I didn’t know about it. Thank you!
Maybe it’s only my naive approach but I thought companies tell something when they integrate a library. I saw the Espressif (ESP32) integration by accident too. :smiley:
Anyway, I’ll contact them!

I think I’ve found the issue.
There is an extra & here:

EDIT:
Sorry, now I see that it was correct.

@kisvegabor Are you sure? It isn’t a pointer:

Edit: and now I saw your edit. :smile:

That’s not the point, that is a globle variable.

But I find something interesting.
this works OK, but the speed is unexceptble, because the cpu is polling in the disp_flush.
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
/SPI transmit data with DMA/
LCD_Send_Data_DMA(area->x1, area->y1, area->x2, area->y2, (uint8_t *)color_p);
while(HAL_SPI_STATE_BUSY_TX == HAL_SPI_GetState(&hspi3))
;
lv_disp_flush_ready(disp_drv);
}

Maybe you aren’t receiving the DMA completion interrupt (or something along those lines).

As you suggested LV_DEMO_SLIDE_SHOW is enabled.

As well as the LV_LOG_LEVEL_TRACE . and trace level was set to LV_LOG_LEVEL_INFO.

the following is the trace I caught when the dma mode didn’t work properly.

Info: lv_init ready (…\LVGL\lvgl\src\lv_core\lv_obj.c #117)
Info: Screen create ready (…\LVGL\lvgl\src\lv_core\lv_obj.c #211)
Info: Screen create ready (…\LVGL\lvgl\src\lv_core\lv_obj.c #211)
Info: Screen create ready (…\LVGL\lvgl\src\lv_core\lv_obj.c #211)
Info: image created (…\LVGL\lvgl\src\lv_objx\lv_img.c #108)
Info: lv_img_set_src: LV_IMG_SRC_VARIABLE type found (…\LVGL\lvgl\src\lv_objx\lv_img.c #152)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: button matrix created (…\LVGL\lvgl\src\lv_objx\lv_btnm.c #127)
Info: tab view created (…\LVGL\lvgl\src\lv_objx\lv_tabview.c #184)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: page created (…\LVGL\lvgl\src\lv_objx\lv_page.c #167)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: page created (…\LVGL\lvgl\src\lv_objx\lv_page.c #167)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: page created (…\LVGL\lvgl\src\lv_objx\lv_page.c #167)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: page created (…\LVGL\lvgl\src\lv_objx\lv_page.c #167)
Info: label created (…\LVGL\lvgl\src\lv_objx\lv_label.c #154)
Info: text area created (…\LVGL\lvgl\src\lv_objx\lv_ta.c #193)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: page created (…\LVGL\lvgl\src\lv_objx\lv_page.c #167)
Info: list created (…\LVGL\lvgl\src\lv_objx\lv_list.c #148)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: button created (…\LVGL\lvgl\src\lv_objx\lv_btn.c #145)
Info: image created (…\LVGL\lvgl\src\lv_objx\lv_img.c #108)
Info: label created (…\LVGL\lvgl\src\lv_objx\lv_label.c #154)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: button created (…\LVGL\lvgl\src\lv_objx\lv_btn.c #145)
Info: image created (…\LVGL\lvgl\src\lv_objx\lv_img.c #108)
Info: label created (…\LVGL\lvgl\src\lv_objx\lv_label.c #154)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: button created (…\LVGL\lvgl\src\lv_objx\lv_btn.c #145)
Info: image created (…\LVGL\lvgl\src\lv_objx\lv_img.c #108)
Info: label created (…\LVGL\lvgl\src\lv_objx\lv_label.c #154)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: button created (…\LVGL\lvgl\src\lv_objx\lv_btn.c #145)
Info: image created (…\LVGL\lvgl\src\lv_objx\lv_img.c #108)
Info: label created (…\LVGL\lvgl\src\lv_objx\lv_label.c #154)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: button created (…\LVGL\lvgl\src\lv_objx\lv_btn.c #145)
Info: image created (…\LVGL\lvgl\src\lv_objx\lv_img.c #108)
Info: label created (…\LVGL\lvgl\src\lv_objx\lv_label.c #154)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: button created (…\LVGL\lvgl\src\lv_objx\lv_btn.c #145)
Info: image created (…\LVGL\lvgl\src\lv_objx\lv_img.c #108)
Info: label created (…\LVGL\lvgl\src\lv_objx\lv_label.c #154)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: button created (…\LVGL\lvgl\src\lv_objx\lv_btn.c #145)
Info: image created (…\LVGL\lvgl\src\lv_objx\lv_img.c #108)
Info: label created (…\LVGL\lvgl\src\lv_objx\lv_label.c #154)
Info: container created (…\LVGL\lvgl\src\lv_objx\lv_cont.c #113)
Info: label created (…\LVGL\lvgl\src\lv_objx\lv_label.c #154)
Info: mesasge box created (…\LVGL\lvgl\src\lv_objx\lv_mbox.c #125)
Info: button matrix created (…\LVGL\lvgl\src\lv_objx\lv_btnm.c #127)
Info: chart created (…\LVGL\lvgl\src\lv_objx\lv_chart.c #140)
Info: bar created (…\LVGL\lvgl\src\lv_objx\lv_bar.c #116)
Info: slider created (…\LVGL\lvgl\src\lv_objx\lv_slider.c #104)
Info: image draw: cache miss, cached to an empty entry (…\LVGL\lvgl\src\lv_draw\lv_img_cache.c #109)

I think the comlete interrupt is received.

The benchmark runs very well, and the score is very high. About twice faster compared to flush without dma.
So this is very strange, in dma mode, some test case work, others don’t.

However, when I send without dma.Everything is just fine.All the test cases run properly.

That means that something is wrong with your DMA-enabled driver.

What happens in the demo if you use a smaller display buffer? E.g. LV_HOR_RES_MAX * 2.