2017-04-16 06:02 PM
Hi
I am using Nucleo F412ZG (with STM32F412ZGT6) + TFT LCD 320x240 ILI9341 with 8bit parallel interface over FSMC - IDE is AC6 System Workbench for STM32 along with STemWin 532
I know that GUIDRV_FlexColor does support ILI9341 - I am looking for help on how to use this. Can anyone please help me with sample code? In a simple test set up, I wrote code for LCDWriteReg, LCDWriteData, LCDInit etc.over FSMC and a test function to fill the LCD screen with blue color and it works fine. But I need this to work with GUIDRV_FlexColor and with STemWin so that I can use all graphics and widgets library.
Appreciate your prompt help
Thanks in advance
Silas
2017-04-17 02:33 AM
Posted on April 17, 2017 at 11:33
Hello Valera.Silas,
I recommend you to run and have a look to the Stemwin example in the STM32CubeF4 at this path, it may be very helpful as a starting point:
You can refer to your reference manual related to your device for more clarification about the LCD-TFT Display Controller (LTDC) section.
Imen
2017-04-18 07:29 PM
Hi Imen,
Thanks for your reply and information.
For my setup, I created LCDConf.c with the required LCD read and write functions along with the following LCD_X_Config function. The LCDInit function also includes code to fill the screen with blue color. Also included the lib - STemWin532_CM4_GCC.a into linker. The code compiles fine without any error. But when I run/debug the LCD screen does not show any color / activity. When I tried to debug (see 'main' code below), single stepping, after the line GUI_Init() - it just hangs, it should go to LCD_X_Config() - but it just hangs
:(
What am I missing? would you please help..Thanks
Silas V
void LCD_X_Config(void) {
GUI_DEVICE * pDevice; CONFIG_FLEXCOLOR Config = {0}; GUI_PORT_API PortAPI = {0}; // // Set display driver and color conversion // pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0); // // Display driver configuration, required for Lin-driver // LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS); LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS); // // Orientation // Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y; GUIDRV_FlexColor_Config(pDevice, &Config); // // Set controller and operation mode // PortAPI.pfWrite8_A0 = LcdWriteReg; PortAPI.pfWrite8_A1 = LcdWriteData; PortAPI.pfWriteM8_A1 = LcdWriteDataMultiple; PortAPI.pfReadM8_A1 = LcdReadDataMultiple;GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C1B8); //for ILI9341, 16bpp + cache + 8bit interface}//Main code:
int main(void)
{/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();/* Configure the system clock */
SystemClock_Config();/* Initialize all configured peripherals */
MX_GPIO_Init(); MX_FSMC_Init(); MX_TIM6_Init(); MX_RTC_Init();/* USER CODE BEGIN 2 */
GUI_Init();
HAL_TIM_Base_Start_IT(&htim6);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE *//* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */}
2017-04-19 09:47 AM
Hi,
The CRC must be enabled before calling GUI_Init, if not STemWin will be not function.
This is mentioned in the AN4323 to call GUI_Init function prior to use any STemWin function or GUI routines:The CRC module (in RCC peripheral clock enable register) should be enabled before using the library.
Thanks
Imen
2017-04-21 12:49 PM
Hi Imen,
Thanks again for your reply:) I missed that. I enabled the CRC in the STM32CubeMX for the project and then built the project - and it seems to work - kind of - at least I can see some activity on the LCD screen. But the display shows not full - half the screen is black and half is colored.
Here is my question: for the LCD, when writing to register - the registers addresses are normally 8bit and data is either 8bit or 16bit - like register setting or color values. How does FSMC handle 16bit color values to write over the bus in 8bit mode? Do I need to write high byte and low byte in two code lines? that means the pointer function passed to
PortAPI.pfWrite8_A1 should take 16bit values - but there is no such valid interface for 8bit mode. That is confusing:(
Would you please help ..
Thanks
Silas
I want to confirm my set up - I am trying to use LCD with 8 bit interface over FSMC. The following are the hardware connections:
FSMC Port LCD Connector on Nucleo
FSMC_D4 PA2 D4 12--35 FSMC_D5 PA3 D5 12--37 FSMC_D6 PA4 D6 11--32 FSMC_D7 PA5 D7 12--11 FSMC_NWE PC2 WR/ 11--35 FSMC_NOE PC5 RD/ 12--6 FSMC_D2 PC11 D2 11--2 FSMC_D3 PC12 D3 11--3 FSMC_NE1 PD7 CS/ 11--45 FSMC_D0 PD14 D0 12--46 FSMC_D1 PD15 D1 12--48 FSMC_A16 PD11 RS 12--45 L-Command, H-DataLCD_RST PB15 RST 12--26In LCDConf.c I have the following declaration for the LCD data/register writes, LCDread is not implemented since I am using the memory buffer -
♯ define LCD_REG (*(uint8_t *)0x60000000) // A16 low for writing to reg
♯ define LCD_DATA (*(uint8_t *)0x60010000) // A16 high for writring datavoid LcdWriteReg(U8 Data) {
// ... TBD by user LCD_REG = Data;}
void LcdWriteData(U8 Data) {
// ... TBD by user LCD_DATA = Data;}
void LcdWriteDataMultiple(U8 *pData, int NumItems) {
while (NumItems) { // ... TBD by user LcdWriteData((uint8_t) *pData) ; pData++; NumItems--;}
}void LCD_X_Config(void) {
GUI_DEVICE * pDevice; CONFIG_FLEXCOLOR Config = {0}; GUI_PORT_API PortAPI = {0}; // // Set display driver and color conversion // pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0); // // Display driver configuration, required for Lin-driver // LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS); LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS); // // Orientation // Config.Orientation = 0; //GUI_SWAP_XY | GUI_MIRROR_Y; GUIDRV_FlexColor_Config(pDevice, &Config); // // Set controller and operation mode // PortAPI.pfWrite8_A0 = LcdWriteReg; PortAPI.pfWrite8_A1 = LcdWriteData; PortAPI.pfWriteM8_A1 = LcdWriteDataMultiple; PortAPI.pfReadM8_A1 = LcdReadDataMultiple; GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C1B8);}2017-05-01 08:15 PM
This set up did not work for me.
Can anyone help me on this? Really appreciate..:)
Thanks
Silas