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.

TM4C129XNCZAD: Double Buffer for Graphics

Former Member
Former Member
Part Number: TM4C129XNCZAD

Customer has dev kit DK-TM4C129X-DK (TM4C129XNCZAD) and attached 480x272 raster display and external SRAM for testing.

They are trying to get the double buffering working on the Tiva C with graphics. They are using the grlib_raster_driver_16bpp library. They have looked at the example, but it only covers the single buffered option. They have tried to make the changes below, but do not think it is working as the screen flashes every time they update it.

MAP_LCDDMAConfigSet(LCD0_BASE, LCD_DMA_BURST_16 | LCD_DMA_FIFORDY_128_WORDS | LCD_DMA_PING_PONG);

    //

    // Set up the frame buffer.  Note that we allow this buffer to extend

    // outside the available SRAM.  This allows us to easily test modes where

    // we can't fit the whole frame in memory, realizing, of course, that

    // part of the display will contain crud.

    //

    MAP_LCDRasterFrameBufferSet(LCD0_BASE, 0, g_pui32DisplayBuffer,

                                SIZE_PALETTE + SIZE_BUFFER);

   

    //second

    MAP_LCDRasterFrameBufferSet(LCD0_BASE, 1, g_pui32DisplayBuffer2,

                                SIZE_PALETTE + SIZE_BUFFER);

 

    //

    // Write the palette to the frame buffer.

    //

    MAP_LCDRasterPaletteSet(LCD0_BASE,

                            LCD_PALETTE_SRC_24BIT| LCD_PALETTE_TYPE_DIRECT,

                            (uint32_t *)g_pui16Palette, g_pulSrcPalette, 0,

                            (SIZE_PALETTE / 2));

 

    //second pallet buffer

      //

    // Write the palette to the frame buffer.

    //

    MAP_LCDRasterPaletteSet(LCD0_BASE,

                            LCD_PALETTE_SRC_24BIT| LCD_PALETTE_TYPE_DIRECT,

                            (uint32_t *)g_pui16Palette2, g_pulSrcPalette, 0,

                            (SIZE_PALETTE / 2));

 

    //

    // Enable the LCD interrupts.

    //

    MAP_LCDIntEnable(LCD0_BASE, (LCD_INT_DMA_DONE | LCD_INT_SYNC_LOST |

                     LCD_INT_UNDERFLOW | LCD_INT_EOF0));

Please advise if there is an issue with the code above or if there is a working example.

Thanks,
Brian

  • Hi Brian,
    There is a note associated with the LCDDMAConfigSet in the User's guide. Please find below. Would you add LCD_DMA_BURST_16 to the call and see if it makes a difference?

    Note:
    DMA burst size LCD_DMA_BURST_16 should be set when using frame buffers in external,
    EPI-connected memory. Using a smaller burst size in this case is likely to result in occasional
    FIFO underflows and associated display glitches.
  • Hi Brian,
    There is a LCD example in section 18.3 of the TivaWare Peripheral Driver Library User's guide. However, it is for single buffer. When the single buffer is used, does the result come out worst compared to the dual buffers or no difference or better?
  • Hi Charles,

    If I may (having been IN the display biz) most all "Single Buffered Memory Schemes" will suffer "Memory Bus Contention" when a, "Display Write" occurs during the "Active Scan" (Display Read) of the Single Buffered Memory.      Such contention is (very) recognizable (disturbing) upon the display - and normally deemed,  "Unacceptable!"

    A "Double Buffered Memory" provides the "possibility"  (but not the assurance) - to enable "Display Writes" - to a "separated memory area" ... (even) during the Active Scan of the other (presently scanned) memory.     It usually proves insufficient to, "Just supply a larger memory."     This is so as the "Active Scan" must not be impacted by any "Display Writes" - especially   "those occurring during the "Active Scan."

    It may prove, "Outside the capability" of the MCU to, "Continually & Correctly" retrieve data (from one portion of memory) while "Display Writes" (to a separate memory area) are (near) simultaneously in progress!

    Such can be detected by monitoring the Address Bus - and observing if the "linear address sequencing"  (noted during, "Non-Write Intervals") becomes "broken/distorted" - during memory writes.     Another means to "Detect such "Double Buffer" capability" - would be to confirm that,  "An MCU write to "Memory Bank_2" - launched "just after" a "memory read" - can occur quickly enough - so as,  "Not to delay" the, "Very next Memory Read from Bank_1."    (such will "disturb" the display!)

  • Hi cb1,
    Thank you for the guidance and sharing your knowledge. I know so well that you are in the display business for a long time. :-) I understand that dual buffer is the preferred method as it is also documented in the datasheet. My rationale for asking to test if the single buffer produce any result that is worst, no difference or better is to understand if there is any DMA setup issue in dual buffer mode or the limitation is simply due to the EPI interface bottleneck. If the single buffer mode produces no difference or even better result than the dual-buffer mode then there could be some DMA setup issue. Certainly we expect the single buffer to produce much worst result. I can't comment on the 480x272 display whether it is too big for the TM4C to handle. The TivaWare example uses a smaller display. Another thing for the poster to check is on the SRAM configuration and the type of SRAM. Will a faster SRAM device help?

    BTW, I didn't spot anything wrong with the poster's code.
  • Hi Charles,

    I much doubt that a, "Faster SRAM" will help.     The issue is most surely w/in the MCU - not external memory.

    I've added two simple tests to my (earlier) posting.      (Likely arrived during your post's composition.)

    If you will - look closely at my (added) final sentence - which may supply the "Death Knell" - to this Double Buffer attempt...

    The timing demands of a "480x272" TFT - most likely "bump against/encroach" the limits - of a 120MHz MCU.   (even IF double buffering IS accommodated - especially if - double buffering is accommodated!)

  • Hi cb1,
    I just read your prior reply again. Based on your experience will you be able to comment what display resolution a 120MHz MCU can support? I think that buffering using internal SRAM will help but the available SRAM size will limit the display size.
  • Hi Charles,

    Do consider - a successful, "Double Buffering" (usually [saving word])  DEMANDS the, "FILL of one Buffer" - at a rate "at or faster" - than the, "Emptying of the other!"    (love that language!)     And - vitally - the "Load of one buffer - must not impact the "Unloading of the other!"     Indeed this places "high demands" upon the Memory Controller - that should (now) be apparent.

    In the 1990s - we bumped against this contention issue.     We initially "solved" this by employing a, "Second Memory Area" - which we could not load  - w/in one display frame.      Thus - switching between "Memory Areas" - required multiple "display frames passage."     Only when the "new" memory was completely loaded - AND - the active memory area had just been unloaded & displayed  - could we, "Switch to the new/second memory area!     This reduced the display's update rate - yet clients considered this "double buffering" an improvement.

    Poster's 480x272 - especially at 16-18 bit "color depth" - is one of my "favs" - yet proves "highly demanding."    (from memory - I recall the "dot clock" of such displays to be at/around 9MHz - and that's CONTINUOUS!)

    Thus - slower clocked MCUs (i.e. TM4C family) - I suspect - (may) prove possible to "Double Buffer" TFTs up to/around QVGA.    (320x240 pixels)      This proves possible as the "dot clock" is greatly reduced - yet  I've NOT, "Run the numbers" - that IS the responsibility of the poster.

    If this poster has, "Heart Set" upon the 4.3" TFT (480x272) - the use of a (proper) TFT Control IC (SSD or Epson) should be investigated.    (SSD = Solomon-Systech,  check SSD1963)