AnsweredAssumed Answered

STM32F4DISCOVERY + STM3210E-EVAL LCD

Question asked by kovaliov.nikolaj on Jul 14, 2013
Good day,

I connected the LCD from STM3210E-EVAL board (SPFD5408B controller) to STM32F4DISCOVERY board.
The problem is I get the ID (0x5408) of the LCD, but I cannot make the LCD to show something.

Here is my code:


#define LCD_REG      (*((volatile short *) 0x60000000)) 
#define LCD_RAM      (*((volatile short *) 0x60020000)) 

main.c:

STM3210E_LCD_Init();
     
  sendstring("\nstart");
     sprintf(to_uart, "\n%d", LCD_ReadReg(0x0000));
     sendstring(to_uart);
  
     LCD_WriteReg(0x0020,height-1);
  LCD_WriteReg(0x0021,width-1);      
  LCD_WriteReg(0x0050,0x00);
  LCD_WriteReg(0x0051,height-1);
  LCD_WriteReg(0x0052,0x00);
  LCD_WriteReg(0x0053,width-1);
  LCD_WriteReg(0x0003,0x1008);
  LCD_WriteRAM_Prepare();
   
     for(x = 0; x < width; x++){
  for(y = 0; y < height; y++){
     LCD_RAM = 0x001F;
  }}

void LCD_CtrlLinesConfig(void)
{
  GPIO_InitTypeDef GPIO_InitStructure; 
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOB, ENABLE);


        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
     GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
     GPIO_Init(GPIOD, &GPIO_InitStructure);
     GPIO_ResetBits(GPIOD , GPIO_Pin_7);           //CS=0;
     
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
     GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
     GPIO_Init(GPIOB, &GPIO_InitStructure);
     GPIO_ResetBits(GPIOB , GPIO_Pin_0);


     /* Enable GPIOs clock */
     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE , ENABLE);
     
     /* Enable FSMC clock */
     RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); 


     /*-- GPIOs Configuration ------------------------------------------------------*/
     /*
     +-------------------+--------------------+------------------+------------------+
     +                       SRAM pins assignment                                   +


     +-------------------+--------------------+
     */
     /* GPIOD configuration */
          /* Set PD.00(D2), PD.01(D3), PD.04(NOE), PD.05(NWE), PD.08(D13), PD.09(D14),
      PD.10(D15), PD.11(A16), PD.14(D0), PD.15(D1) as alternate function push pull */
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource4, GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource10, GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource11, GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_FSMC);
     
     //CS(FSCM_NE4) PD07 1
     //RS(FSCM_A16) PD11 2
     //WR(FSCM_NWE) PD05 3
     //RD(FSCM_NOE) PD04 4
     //RESET        PB00 5
     //D0           PD14 6
     //D1                     PD15 7
     //D2                       PD00 8 
     //D3                       PD01 9
     //D4                       PE07 10
     //D5                       PE08 11
     //D6                       PE09 12
     //D7                    PE10 13
     //D8                       PE11 14
     //D9                       PE12 15
     //D10                      PE13 16
     //D11                      PE14 17
     //D12                      PE15 18
     //D13                      PD08 19
     //D14                      PD09 20
     //D15                      PD10 21
     
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | 
                                 GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 |
                                         GPIO_Pin_14 | GPIO_Pin_15;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
     
     GPIO_Init(GPIOD, &GPIO_InitStructure);
     
     /* Set PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9), PE.13(D10),
      PE.14(D11), PE.15(D12) as alternate function push pull */     
     /* GPIOE configuration */
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource2 , GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource7 , GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource8 , GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource9 , GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource10 , GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource11 , GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource12 , GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource13 , GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource14 , GPIO_AF_FSMC);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource15 , GPIO_AF_FSMC);
     
     GPIO_InitStructure.GPIO_Pin =GPIO_Pin_2 | GPIO_Pin_7 | GPIO_Pin_8  | GPIO_Pin_9  | GPIO_Pin_10 |
                                  GPIO_Pin_11| GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
     
     GPIO_Init(GPIOE, &GPIO_InitStructure);
     
}




/**
  * @brief  Configures the Parallel interface (FSMC) for LCD(Parallel mode)
  * @param  None
  * @retval None
  */
void LCD_FSMCConfig(void)
{
     
  FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
     FSMC_NORSRAMTimingInitTypeDef FSMC_NORSRAMTimingInitStructure;
     
     RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);


     FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
     FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
     FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
     FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
     FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
     FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
     FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
     FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
     FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
     FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
     FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
     FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
     FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
     FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;




     
     FSMC_NORSRAMTimingInitStructure.FSMC_AddressSetupTime = 15;//1;
     FSMC_NORSRAMTimingInitStructure.FSMC_AddressHoldTime = 0;        
     FSMC_NORSRAMTimingInitStructure.FSMC_DataSetupTime = 15;//1;      
     FSMC_NORSRAMTimingInitStructure.FSMC_BusTurnAroundDuration = 0;
     FSMC_NORSRAMTimingInitStructure.FSMC_CLKDivision = 0;
     FSMC_NORSRAMTimingInitStructure.FSMC_DataLatency = 0;
     FSMC_NORSRAMTimingInitStructure.FSMC_AccessMode = FSMC_AccessMode_A;     
     FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;       
     
     FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); 
     
     
     FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
}

Outcomes