AnsweredAssumed Answered

Using iSTemWin + FMC with 16 bit interface

Question asked by jorge guzman on Sep 21, 2017
Latest reply on Sep 25, 2017 by Vangelis Fortounas

Imen D


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;

 

#define FMC_BANK1_SRAM3_BASE  ((uint32_t)(0x60000000 | 0x08000000))

 

/* Selecionao banco que sera usado*/

#define 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

Attachments

Outcomes