cancel
Showing results for 
Search instead for 
Did you mean: 

Using iSTemWin + FMC with 16 bit interface

jorge guzman
Associate
Posted on September 21, 2017 at 22:26

DAHMEN.IMEN

‌

Hello,

I'm trying to use TFT display with ILI9341 16 bit interface with STM32F427 via FMC.  I based my code looking the samples gerates for CubeMX.

I am using FreeRTOS and STemWin to print the 'Hello Word' message, but it does not work, in this case I have not found many examples of how to use the FMC.

I created the file stm32f427xx_eval.c with the routines that StemWim will use to write to the lcd.

typedef struct

{

 __IO uint16_t REG; /* Read Register */

 __IO uint16_t RAM; /* Read RAM */

}LCD_CONTROLLER_TypeDef;

&sharpdefine FMC_BANK1_SRAM3_BASE  ((uint32_t)(0x60000000 | 0x08000000))

/* Selecionao banco que sera usado*/

&sharpdefine FMC_BANK3       ((LCD_CONTROLLER_TypeDef *) FMC_BANK1_SRAM3_BASE)

void BSP_LCD_Init(void)

{    

 /* Backlight control signal assertion */

LCD_BACKLIGHT_ON();

 

 /* Apply hardware reset according to procedure indicated in FRD154BP2901 documentation */

LCD_RESET();

 

 ili9341_Init();

}

/*******************************************************************************

                           BUS OPERATIONS

*******************************************************************************/

/**

 * @brief  Writes register value.

 * @param  Data: Data to be written

 */

void FSMC_BANK3_WriteData(uint16_t Data)

{

 /* Write 16-bit Reg */

 FMC_BANK3->RAM = Data;

}

/**

 * @brief  Writes register address.

 * @param  Reg: Register to be written

 */

void FSMC_BANK3_WriteReg(uint8_t Reg)

{

 /* Write 16-bit Index, then write register */

 FMC_BANK3->REG = Reg;

}

/**

 * @brief  Reads register value.

 * @retval Read value

 */

uint16_t FSMC_BANK3_ReadData(uint16_t xRegValue, uint8_t xReadSize)

{

 return (FMC_BANK3->RAM);

}

/********************************* LINK LCD ***********************************/

/**

 * @brief  Initializes LCD low level.

 */

void LCD_IO_Init(void)

{

 if(Is_LCD_IO_Initialized == 0)

 {

   Is_LCD_IO_Initialized = 1;     

 }

}

/**

 * @brief  Writes data on LCD data register.

 * @param  Data: Data to be written

 */

void LCD_IO_WriteData(uint16_t Data)

{

 /* Write 16-bit Reg */

 FSMC_BANK3_WriteData(Data);

}

/**

 * @brief  Write register value.

 * @param  pData Pointer on the register value

 * @param  Size Size of byte to transmit to the register

 */

void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size)

{

 uint32_t counter;

 uint16_t *ptr = (uint16_t *) pData;

 

 for (counter = 0; counter < Size; counter+=2)

 {  

   /* Write 16-bit Reg */

   FSMC_BANK3_WriteData(*ptr);

   ptr++;

 }

}

/**

 * @brief  Writes register on LCD register.

 * @param  Reg: Register to be written

 */

void LCD_IO_WriteReg(uint8_t Reg)

{

 /* Write 16-bit Index, then Write Reg */

 FSMC_BANK3_WriteReg(Reg);

}

/**

 * @brief  Reads data from LCD data register.

 * @param  Reg: Register to be read

 * @retval Read data.

 */

uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize)

{

 //FSMC_BANK3_WriteReg(Reg);

 

 /* Read 16-bit Reg */  

 return FSMC_BANK3_ReadData(RegValue, ReadSize);

}

My FMC is configured as follows:

/* FMC initialization function */

static void MX_FMC_Init(void)

{

 FMC_NORSRAM_TimingTypeDef Timing;

 /** Perform the SRAM3 memory initialization sequence

 */

 hsram3.Instance = FMC_NORSRAM_DEVICE;

 hsram3.Extended = FMC_NORSRAM_EXTENDED_DEVICE;

 /* hsram3.Init */

 hsram3.Init.NSBank = FMC_NORSRAM_BANK3;

 hsram3.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;

 hsram3.Init.MemoryType = FMC_MEMORY_TYPE_SRAM;

 hsram3.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16;

 hsram3.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;

 hsram3.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;

 hsram3.Init.WrapMode = FMC_WRAP_MODE_DISABLE;

 hsram3.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;

 hsram3.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;

 hsram3.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;

 hsram3.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;

 hsram3.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE;

 hsram3.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;

 hsram3.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY;

 hsram3.Init.PageSize = FMC_PAGE_SIZE_NONE;

 /* Timing */

 Timing.AddressSetupTime = 15;

 Timing.AddressHoldTime = 15;

 Timing.DataSetupTime = 255;

 Timing.BusTurnAroundDuration = 15;

 Timing.CLKDivision = 16;

 Timing.DataLatency = 17;

 Timing.AccessMode = FMC_ACCESS_MODE_A;

 /* ExtTiming */

 if (HAL_SRAM_Init(&hsram3, &Timing, NULL) != HAL_OK)

 {

   _Error_Handler(__FILE__, __LINE__);

 }

}

Has anyone ever had the same problem?

Thanks,

Jorge

#fmc #stemwin
4 REPLIES 4
Posted on September 25, 2017 at 14:22

Hello Jorge!

Code seems functional.

But is not enough to sucessfully display the 'Hello world'

What about LCD_conf andGUI_conf  files?

I suggest to remove the

FreeRTOS until you have fully functional the LCD (after, you can use it with minor changes to your code).

When first time connected a 16 bit LCD to FMC it tooks me at least 10 days to make it work (needs good study of LCD's UM)

Do you have some schematic to post? (connections between LCD and FMC also the IM[3:0]  pins)  It will helps the community to advise you.

Regards

vf

Imen.D
ST Employee
Posted on September 25, 2017 at 15:00

Hello,

Please check clock of CRC module is enabled. GUI_Init () needs crc module, 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.'

'Note that before initializing the GUI, the CRC module (in RCC peripheral clock enable register) should be enabled.'

Also, it would be better to increase the size of the memory requirement of your application.

Best Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on September 25, 2017 at 15:13

Hello Vangelis,

Thanks for answering, this is the connection i'm using.

0690X00000608M4QAI.png

I shared all the project in

https://community.st.com/servlet/JiveServlet/download/43760-1-9628/Project1.zip

for more details.

This is the configuration of my

GUIConf.c file.

/* 32 bit aligned memory area */

static U32 extMem[GUI_NUMBYTES / 4];

void GUI_X_Config(void)

{

// Assign memory to emWin

GUI_ALLOC_AssignMemory(extMem, GUI_NUMBYTES);

// Set default font

// GUI_SetDefaultFont(GUI_FONT_6X8);

}

End

This is the configuration of myLCD

Conf.c file

static void LcdWriteReg(U16 Data)

{

FSMC_BANK3_WriteReg(Data);

}

static void LcdWriteData(U16 Data)

{

FSMC_BANK3_WriteData(Data);

}

static void LcdWriteDataMultiple(U16 * pData, int NumItems)

{

while (NumItems--)

{

FSMC_BANK3_WriteData(*pData++);

}

}

static void LcdReadDataMultiple(U16 * pData, int NumItems)

{

while (NumItems--)

{

*pData++ = FSMC_BANK3_ReadData(0, 0);

}

}

void LCD_LL_Init(void)

{

/* LCD Init */

BSP_LCD_Init();

}

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_M565, 0, 0);

/* Display driver configuration, required for Lin-driver */

LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);

LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);

Config.Orientation = GUI_MIRROR_X | GUI_MIRROR_Y;

GUIDRV_FlexColor_Config(pDevice, &Config);

/* Set controller and operation mode */

PortAPI.pfWrite16_A0 = LcdWriteReg;

PortAPI.pfWrite16_A1 = LcdWriteData;

PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;

PortAPI.pfReadM16_A1 = LcdReadDataMultiple;

GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B16);

}

I really don't no know whats wrong.

Regards

Jorge Guzman

Posted on September 25, 2017 at 17:47

Hello again!

The BSP function void ili9341_Init(void)

initializes the ILI9341 to RGB mode that is compatible with STM32f429 discovery board.

Make some search to find a more appropriate initialization sequence.

I use same controller in SPI mode, When i tried to 'decode' the  initialization code from same BSP, i found that a lot of  commands there was n't in ILITEK datasheet!

But, try  first to read from LCD the ID code to be sure that your other code is functional.

regards

vf