2024-04-23 09:26 AM
I am starting some test with this module
https://it.aliexpress.com/item/1005002482177244.html
with 7” lcd
I have found only one example that run but with Touchgfx
I have got the same ioc from this example to generate a new code and insert the functions to switch on lcd but still no result
I would like to use the normal functions
BSP_LCD_Init() ;
BSP_LCD_DisplayStringAt(10, 80, buf, LEFT_MODE);
BSP_LCD_DrawBitmap(0, 0, (uint8_t *)(&BackGround0));
Solved! Go to Solution.
2024-04-23 10:28 PM
What's the Pixel Clock ?
If you fill the frame buffer with random data do you get a colourful pattern?
2024-04-23 11:13 PM - edited 2024-04-23 11:24 PM
Until now I see only a blue screen
/* ARGB8888 colors definitions */
#define LCD_COLOR_ARGB8888_BLUE 0xFF0000FFUL
#define LCD_COLOR_ARGB8888_GREEN 0xFF00FF00UL
#define LCD_COLOR_ARGB8888_RED 0xFFFF0000UL
BSP_LCD_Clear(LCD_COLOR_ARGB8888_GREEN);
HAL_Delay(1000);
BSP_LCD_Clear(LCD_COLOR_ARGB8888_RED);
last project files for Cube IDE
www.audiodesignguide.com/sw1/stm32F429BI-test4.zip
2024-04-24 01:54 AM - edited 2024-04-24 01:55 AM
Until now I see only a blue screen
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
#define OK1 --> RUN
#ifdef OK1
PeriphClkInitStruct.PLLSAI.PLLSAIN = 60;
PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
#endif
#define KO2 --> NOT RUN
#ifdef KO1
PeriphClkInitStruct.PLLSAI.PLLSAIN = 80; // 60=25MHz, 80=33.3MHz ??
PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
#endif
2024-04-24 02:08 AM
and this hang the system
//int i;
//for (i = 0; i < 10; i++)
// BSP_LCD_DrawPixel(200,100+i, LCD_COLOR_ARGB8888_GREEN);
void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code)
{
/* Write data value to all SDRAM memory */
if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
{ /* RGB565 format */
*(__IO uint16_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))) = (uint16_t)RGB_Code;
}
else
{ /* ARGB8888 format */
*(__IO uint32_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code;
}
}
2024-04-24 06:00 AM
Hangs the system, or Hard Fault's ?
Have the HardFault_Handler() output some actionable data, rather than silent death in while(1). Similarly Error_Handler()
Hard Fault would suggest the SDRAM is not working or at wrong address. Check SDRAM, check pointers.
What does Cube say about PLL SAI settings for 33.33 MHz ? Also #define / #ifdef use different key word.
2024-04-24 06:03 AM
In the china example I have found this set for 33Mhz
#define LCD_CLK 33 // 33MHz
void LCD_Init(void)
{
u16 LCD_PLLSAIN = 0;
u8 LCD_PLLSAIR = 3;
u8 LCD_CLKDIV = 2;
LTDC_InitTypeDef LTDC_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);
LCD_GPIO_Config();
LCD_PLLSAIN = LCD_CLK * LCD_PLLSAIR * LCD_CLKDIV;
RCC_PLLSAIConfig(LCD_PLLSAIN,7,LCD_PLLSAIR);
RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div2)
RCC_PLLSAICmd(ENABLE);
so I have set
#define LCD_CLK 33
uint16_t LCD_PLLSAIN = 0;
uint8_t LCD_PLLSAIR = 3;
uint8_t LCD_CLKDIV = 2;
PeriphClkInitStruct.PLLSAI.PLLSAIN = LCD_CLK * LCD_PLLSAIR * LCD_CLKDIV;
PeriphClkInitStruct.PLLSAI.PLLSAIR = LCD_PLLSAIR;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
but not work
2024-04-24 06:21 AM
>>but not work
Ok but your Cube project had HSE at 25 MHz, and the prescaler in the PLL as 15, so the comparison frequency is 1.6667 MHz
Your primary PLL multiplier is 144, getting the VCO to 240 MHz, and CPU at 120 MHz
Check what the LTDC clock is in your Cube Clock Tree, rather than lift codes from the other app with different expectations.
a) Confirm the 60 value relates to 25 MHz LTDC / PIXEL CLOCK
b) Confirm the 80 value relates to 33.33 MHz and doesn't violate any parameters Cube is checking.
#define KO2 --> NOT RUN, perhaps no clocking at all, as names different
#ifdef KO1
2024-04-24 06:56 AM
Here we have:
void SystemClock_Config(void)
{
....
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 15;
RCC_OscInitStruct.PLL.PLLN = 144;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 5;
...
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
PeriphClkInitStruct.PLLSAI.PLLSAIN = 60;
PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
and here we have:
void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc)
{
...
PeriphClkInitStruct.PLLSAI.PLLSAIN = 60;
PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
but if I set the new parameters to have 33MHz I see only a black screen and no blue screen
void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc)
PeriphClkInitStruct.PLLSAI.PLLSAIN = 80; // 60=25MHz, 80=33.3MHz ??
PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
or
#define LCD_CLK 33
uint16_t LCD_PLLSAIN = 0;
uint8_t LCD_PLLSAIR = 3;
uint8_t LCD_CLKDIV = 2;
PeriphClkInitStruct.PLLSAI.PLLSAIN = LCD_CLK * LCD_PLLSAIR * LCD_CLKDIV;
PeriphClkInitStruct.PLLSAI.PLLSAIR = LCD_PLLSAIR;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
2024-04-24 07:59 AM
Ok, need to understand the hanging. Check the Hard Faulting situation.
Blue / Black doesn't make a lot of sense.
Try pointing the LTDC Frame Buffer at the 0x08000000 FLASH address, should see more colourful data reflective of the opcodes in the firmware, and perhaps white when it gets to the 0xFFFFFFFF patterns.
Trying to establish if the issue is with the memory transfer, or the timings, or something else
The minimum frequency in the screen spec is 26.4 MHz
2024-04-24 11:21 AM
if (HAL_LTDC_Init(&hltdc) != HAL_OK)
{
Error_Handler();
}
pLayerCfg.WindowX0 = 0;
pLayerCfg.WindowX1 = 799;
pLayerCfg.WindowY0 = 0;
pLayerCfg.WindowY1 = 479;
pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
pLayerCfg.Alpha = 255;
pLayerCfg.Alpha0 = 0;
pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
pLayerCfg.FBStartAdress = 0x08000000 ; // x 0xD0000000
pLayerCfg.ImageWidth = 800;
pLayerCfg.ImageHeight = 480;
pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0;