Code to replicate double-draw glitch on ST dev board. Program draws full-screen Red->Green->Blue into back-buffer, then swaps the LTDC layer source buffer before repeating. This should result in a solid blue screen, but produces a visible glitch with parts of the screen flashing red and green.
Dependencies: BSP_DISCO_F746NG
Diff: main.cpp
- Revision:
- 2:a19deff061e8
- Parent:
- 1:d515deceeccc
- Child:
- 3:5ceff0955fb1
--- a/main.cpp Fri Mar 27 07:18:57 2020 +0000 +++ b/main.cpp Fri Mar 27 07:39:08 2020 +0000 @@ -1,6 +1,10 @@ #include "mbed.h" #include "stm32746g_discovery_sdram.h" +//If 0 then always draw to front buffer +//else always draw to back buffer +#define DOUBLE_BUFFER 0 + const uint32_t SDRAM_BANK1_ADDR=0xC0000000; const uint32_t SDRAM_BANK_SIZE =0x200000; const uint32_t SDRAM_BANK2_ADDR=SDRAM_BANK1_ADDR+SDRAM_BANK_SIZE; @@ -170,6 +174,7 @@ void transferCompleteHandler() { queue->call(printf,"TC\n"); + #if DOUBLE_BUFFER if(updated==2) { swapping=false; updated=0; @@ -177,12 +182,19 @@ cont=false; } if(line||(buffer.empty()&&(updated>0))) flip(); else draw(); + #else + draw(); + #endif } void lineHandler() { queue->call(printf,"LN\n"); + #if DOUBLE_BUFFER if(running==true) line=true; else if(updated>0) flip(); else draw(); + #else + draw(); + #endif } void flip() { @@ -219,6 +231,9 @@ if(DMA2D->CR&0x01) return false; if(buffer.empty()) { running=false; + #if !DOUBLE_BUFFER + cont=false; + #endif return false; } queue->call(printf,"DRAW\n"); @@ -227,7 +242,11 @@ buffer.pop(color); DMA2D->OPFCCR=2; DMA2D->OCOLR=(uint32_t)color; + #if DOUBLE_BUFFER DMA2D->OMAR=backBuffer; + #else + DMA2D->OMAR=frontBuffer; + #endif DMA2D->OOR=0; DMA2D->NLR=(((uint32_t)LCD_WIDTH)<<16)|((uint32_t)(LCD_HEIGHT)); DMA2D->IFCR=0x3F; @@ -252,6 +271,9 @@ color=0x001F; buffer.push(color); cont=true; + #if !DOUBLE_BUFFER + ThisThread::sleep_for(100); + #endif } }