LcdWriteDataMultiple function sends only one line of frame each time.

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • LcdWriteDataMultiple function sends only one line of frame each time.

      I designed a custom board with STM32F413RH and 4DOLED-282815 display. Oled display has 128x128 pixel. I think ram is enough to use stemwin because STM32F413RH has 320 KB RAM and 1.5MByte Flash.
      I want to use stemwin without OS. I rearranged LCDConf(.h/.c) and GUIConf(.h/.c) files. I wrote below inside of LCDWriteDataMultiple function.


      void LcdWriteDataMultipleWithDMA(uint8_t * pData, uint32_t NumItems)
      {
      set_swo_pin();//to see elapsed time in oscilloscope
      HAL_DMA_Start(&hdma_memtomem_dma2_stream0, (uint32_t)pData, (uint32_t)0x6C000001, NumItems);
      HAL_DMA_PollForTransfer(&hdma_memtomem_dma2_stream0, HAL_DMA_FULL_TRANSFER, 10); //This is for test
      reset_swo_pin();//to see elapsed time in oscilloscope
      }

      I write below code to test stemwin with dma.

      GUI_MEMDEV_Handle hMem = GUI_MEMDEV_Create(0,0,128,128);
      while(1){
      GUI_MEMDEV_Select(hMem);
      GUI_Clear();
      GUI_SetBkColor(GUI_RED);
      GUI_SetFont(&GUI_Font32B_ASCII);
      GUI_SetColor(GUI_WHITE);
      GUI_DispStringAt("Text", 10, 20);
      GUI_MEMDEV_CopyToLCD(hMem);
      GUI_MEMDEV_Delete(hMem);
      }

      The code above runs correctly. But when i measure signal on swo pin with logic analzer, I noticed the one data line of frame buffer is send each time. So, to use dma wil not be effective.
      I used internal driver as below code;
      GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66722, GUIDRV_FLEXCOLOR_M16C0B8);

      Is it possible to send frame data with DMA at once? Should I write driver for SSD1351?

      Thanks
    • Hi,

      You are using a a driver version without cache, GUIDRV_FLEXCOLOR_M16C0B8. Without a cache the GUIDRV_FlexColor driver allocates a buffer to hold one line. Therefore it can only send one line at once.

      You are using a memory device but it also gets drawn line by line by the driver, just as a bitmap would be. Instead of using a memory device you could use a cached version of the driver, GUIDRV_FLEXCOLOR_M16C1B8. Now instead of using the memory device you can lock and unlock the cache. This way the cache should be send completely to the HW.

      Try this:

      C Source Code

      1. GUI_MEMDEV_Handle hMem = GUI_MEMDEV_Create(0,0,128,128);
      2. while(1){
      3. LCD_ControlCache(LCD_CC_LOCK);
      4. GUI_Clear();
      5. GUI_SetBkColor(GUI_RED);
      6. GUI_SetFont(&GUI_Font32B_ASCII);
      7. GUI_SetColor(GUI_WHITE);
      8. GUI_DispStringAt("Text", 10, 20);
      9. LCD_ControlCache(LCD_CC_UNLOCK);
      10. }

      After LCD_ControlCache(LCD_CC_LOCK) all drawing operations are getting performed into the cache. On LCD_ControlCache(LCD_CC_UNLOCK) the complete cache gets send to the LCD controller.

      Of course, a cache requires some memory. The requirement is calculated as follows:
      XSIZE_LCD x YSIZE_LCD x Byte per pixel -> 128 x 128 x 2 -> 32KB (if your display has size 128x128 pixels). This memory block gets allocated from the memory set for emWin by calling GUI_ALLOC_AssignMemory(). So, you have to make sure to spend emWin enough memory.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Hi Sven,

      Thanks for the answer. This will solve things in my mind highly. I will try. But before trying, I want to ask you another question.

      After LCD_ControlCache(LCD_CC_UNLOCK), dma will transmit data to LCD. I think time for transmitting data is about 5 ms.
      When dma is active, can I start drawing another frame like double buffering? Do I have to wait dma transmitting to finish?

      Thank you
      Mesut
    • Hi Sven,

      I changed driver command with cache as GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66722, GUIDRV_FLEXCOLOR_M16C1B8);
      I tried test code below;

      LCD_ControlCache(LCD_CC_LOCK);
      GUI_Clear();
      GUI_SetBkColor(GUI_RED);
      GUI_SetFont(&GUI_Font32B_ASCII);
      GUI_SetColor(GUI_WHITE);
      GUI_DispStringAt("Text", 10, 20);
      LCD_ControlCache(LCD_CC_UNLOCK);

      I measured how many LCDWriteDataMultiple function was called. it was called at 128 times, once per line.
      Result has not changed.

      What do you recommend to use frame buffer before sending data to lcd and use dma to send data?

      Thanks
      Mesut