2024-08-24 02:34 AM
Hello everybody,
I want to program a graphics animation for the lcd display of the STM32H7B3I-DK Board. In this project I dont want to rely on other libraries. I want to do everything by myself. That means do the read/write operations to the needed registers myself.
I have already managed to enable the lcd display and initialise the ltdc. Initially I set the background color to green and everything worked fine. My next goal then was to use the layers. I tried to follow the steps provided in RM0455 Reference Manual.
These are the following:
1) Enable the LTDC clock in the RCC register.
2) Configure the required pixel clock following the panel datasheet.
3) Configure the synchronous timings: VSYNC, HSYNC, vertical and horizontal back porch, active data area and the front porch timings following the panel datasheet as described in the Section 36.4.1.
4) Configure the synchronous signals and clock polarity in the LTDC_GCR register.
5) If needed, configure the background color in the LTDC_BCCR register.
6) Configure the needed interrupts in the LTDC_IER and LTDC_LIPCR register.
7) Configure the layer1/2 parameters by:
– programming the layer window horizontal and vertical position in the LTDC_LxWHPCR and LTDC_WVPCR registers. The layer window must be in the active data area.
– programming the pixel input format in the LTDC_LxPFCR register
– programming the color frame buffer start address in the LTDC_LxCFBAR register
– programming the line length and pitch of the color frame buffer in the LTDC_LxCFBLR register
– programming the number of lines of the color frame buffer in the LTDC_LxCFBLNR register
– if needed, loading the CLUT with the RGB values and its address in the LTDC_LxCLUTWR register
– If needed, configuring the default color and the blending factors respectively in the LTDC_LxDCCR and LTDC_LxBFCR registers
😎 Enable layer1/2 and if needed the CLUT in the LTDC_LxCR register
9) If needed, enable dithering and color keying respectively in the LTDC_GCR and LTDC_LxCKCR registers. They can be also enabled on the fly.
10) Reload the shadow registers to active register through the LTDC_SRCR register.
11) Enable the LTDC controller in the LTDC_GCR register.
12) All layer parameters can be modified on the fly except the CLUT. The new configuration must be either reloaded immediately or during vertical blanking period by configuring the LTDC_SRCR register.
I configured everything besides dithering, the interrupts and the blending factor. I also don't use the CLUT. However my code doesn't work properly. In the first step I would like to just fill the layer0 with one color. I want to use the rgb888 color format for this. So I defined my color lookup table to start at the first address of the fmc bank 1 which has 256 MB of space.
There is a lot of other code running in the background that would be too much to post here. But I assume that it works since I already used it in other projects. The code is in c++ and I use the ARM Keil yVision IDE.
These are my configurations:
//LTDC
rbRCC.APB3ENR |= mask_rcc_apb3enr_ltdcen;
rbLTDC.GCR |= mask_ltdc_gcr_pcpol;
rbLTDC.GCR |= mask_ltdc_gcr_hspol;
rbLTDC.GCR |= mask_ltdc_gcr_vspol;
rbLTDC.GCR |= mask_ltdc_gcr_depol;
rbLTDC.SSCR.w = 0x001d0009;
rbLTDC.BPCR.w = 0x002a000b;
rbLTDC.AWCR.w = 0x020a011b;
rbLTDC.TWCR.w = 0x022a011d;
//set background color
rbLTDC.BCCR = static_cast<WORD>(0xFFFFFF);
//layer0 configuration
rbLTDC.layer0.WHPCR = 480U << 16U; // Window horizontal stop position
rbLTDC.layer0.WHPCR |= 44U << 0U; // Window horizontal start position = AHBP + 1
rbLTDC.layer0.WVPCR |= 272U << 16U; // Window vertical stop position
rbLTDC.layer0.WVPCR |= 13U << 0U; // Window vertical start position
//configure the pixel format
rbLTDC.layer0.PFCR |= mask_ltdc_layer_pfcr_pf_rgb888;
//color frame buffer address
rbLTDC.layer0.CFBAR_ptr = (uint32_t*) 0x60000000; //set to begin of FMC Bank 1
rbLTDC.layer0.CFBLR = ((480 * 3) << 16U) | (480 * 3 + 3);
rbLTDC.layer0.CFBLNR = 0x11b;
//fill color frame buffer
uint32_t* frame_buffer = (uint32_t*) 0x60000000;
for (int i = 0; i < (480 * 272); i++) {
frame_buffer[i] = 0x0000FF; //blue
}
//layer default color
rbLTDC.layer0.DCCR = static_cast<WORD>(255U); //blue no alpha
//disable clut
rbLTDC.layer0.CR |= 0U << 4U;
rbLTDC.layer0.CACR = 255U;
//enable the layer
rbLTDC.layer0.CR |= mask_ltdc_layer_cr_len;
//set shadow registers to immediate reload
rbLTDC.SRCR = mask_ltdc_srcr_imr;
//enable LTDC
rbLTDC.GCR |= mask_ltdc_gcr_ltdcen;
Any help is gladly appreciated. Many thanks!
2024-08-26 01:34 AM
Hello @v-c ,
You can use the LTDC examples provided in the STM32CubeH7 repository on GitHub , Specifically, you can refer to the LTDC examples for the STM32H7B3I-DK Board : STM32CubeH7/Projects/STM32H7B3I-DK/Examples/LTDC at master · STMicroelectronics/STM32CubeH7 · GitHub
These examples will guide you in configuring the LTDC correctly for your graphics applications.
BR