Using BSP_LCD library from stm32746g_discovery board on stm32f767zit6 MCU - Page 1
Forum section: electronics / general

author: nitish111
author_rank: Contributor
timestamp: June 15, 2018, 07:06:02 pm
content: Hi,I am trying to learn TFT display with touch capabilities. I am using STM32F767ZIT6 MCU, RK043FN02H-CT TFT with capacitive touch panel and AS4C4M32SA SDRAM. I imported following library from STM32F746g discovery board.#include "stm32746g_discovery.h"#include "stm32746g_discovery_lcd.h"#include "stm32746g_discovery_sdram.h"#include "stm32746g_discovery_ts.h"I corrected pin assignments on the files and uploaded software. I was able to turn on the LCD and initialize it. Then I could not make it display color. After few research I realize that I had FBStartAdress at 0 and then I changed to 0xC0000000. I could see flickers on the screen. Then I entered FBStartAdress = 0x20013dfc. I was getting full color. I was able to draw different shapes (circle,lines, ellipse etc) but when I displaying texts it would print properly on first two lines and then it would display randomly(refer linkhttps://gph.is/2HRzsuP). Here is the code snippet I'm using.#define LCD_FRAME_BUFFER_LAYER0 ((uint32_t)0x20013dfc)BSP_LCD_Init();BSP_LCD_LayerRgb565Init(0, LCD_FRAME_BUFFER_LAYER0);BSP_LCD_SelectLayer(0);BSP_LCD_SetLayerVisible(0, ENABLE);BSP_LCD_Clear(LCD_COLOR_RED);int dummy = 0;while (1){BSP_LCD_SetTextColor(LCD_COLOR_GREEN);BSP_LCD_SetBackColor(LCD_COLOR_BLUE);BSP_LCD_DisplayStringAtLine(dummy,(uint8_t*)"HELLO WORLD!!!");HAL_Delay(500);BSP_LCD_Clear(LCD_COLOR_RED);dummy++;if (dummy>=12) dummy =0;}I have set text color as green but it displays in yellow. I am not sure what is causing the glitch or why color is yellow instead of green. Please refer to stmcube32.png for pin assignment. Refer below for clock configuration.void SystemClock_Config(void){RCC_OscInitTypeDef RCC_OscInitStruct;RCC_ClkInitTypeDef RCC_ClkInitStruct;RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;/**Configure the main internal regulator output voltage*/__HAL_RCC_PWR_CLK_ENABLE();__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);/**Initializes the CPU, AHB and APB busses clocks*/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 = 8;RCC_OscInitStruct.PLL.PLLN = 432;RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;RCC_OscInitStruct.PLL.PLLQ = 2;if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK){_Error_Handler(__FILE__, __LINE__);}/**Activate the Over-Drive mode*/if (HAL_PWREx_EnableOverDrive() != HAL_OK){_Error_Handler(__FILE__, __LINE__);}/**Initializes the CPU, AHB and APB busses clocks*/RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7) != HAL_OK){_Error_Handler(__FILE__, __LINE__);}PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_I2C4;PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2;PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV2;PeriphClkInitStruct.PLLSAIDivQ = 1;PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4;PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_PCLK1;if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK){_Error_Handler(__FILE__, __LINE__);}/**Configure the Systick interrupt time*/HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);/**Configure the Systick*/HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);/* SysTick_IRQn interrupt configuration */HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);}