AnsweredAssumed Answered

SSD1289 STM32CubeF4

Question asked by john on Jul 29, 2014
Latest reply on Jul 29, 2014 by Clive One
I am a beginner with Stm32f4discovery (version stm32f407vg). It took me a long to get the graphic LCD work (copying and rewriting some code from others).

My problem, I want to use it with FreeRTOS. But My FreeRTOS works in Stm32Cube. And my GLCD works in stm32f4firmware. I tried a lot but I can not get FreeRTOS in Stm32f4 firmware in IAR/arm, nor can I get GLCD work with Stm32cube in Keil.

My question. Who can help to rewrite the following code in stm32cubef4? Please help me. Alternatively, who can send me a working project with freertos, stm32f4 firmware in iar/arm. 

Here is the code:

static void LCD_CtrlLinesConfig(void)
{
     GPIO_InitTypeDef GPIO_InitStructure; 
     
     /* 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);
     
     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);
        
        /*The following code is not necessary since PD7 is FSMC_NE1 */
        /*
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
     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);
     GPIO_ResetBits(GPIOD,GPIO_Pin_7);
        */
}


/*******************************************************************************
* Function Name  : LCD_FSMCConfig
* Description    : Configures the Parallel interface (FSMC) for LCD(Parallel mode)
* Input          : None
* Output         : None
* Return         : None
* Attention           : None
*******************************************************************************/
static void LCD_FSMCConfig(void)
{
     FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
     FSMC_NORSRAMTimingInitTypeDef FSMC_NORSRAMTimingInitStructure;
     
     FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;
     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_NORSRAMInit(&FSMC_NORSRAMInitStructure); 




     /* FSMCдËÙ¶ÈÉèÖà */
     FSMC_NORSRAMTimingInitStructure.FSMC_AddressSetupTime = 15;//1;   /* µØÖ·½¨Á¢Ê±¼ä  */
     FSMC_NORSRAMTimingInitStructure.FSMC_AddressHoldTime = 0;        
     FSMC_NORSRAMTimingInitStructure.FSMC_DataSetupTime = 15;//1;        /* Êý¾Ý½¨Á¢Ê±¼ä  */
     FSMC_NORSRAMTimingInitStructure.FSMC_BusTurnAroundDuration = 0x00;
     FSMC_NORSRAMTimingInitStructure.FSMC_CLKDivision = 0x00;
     FSMC_NORSRAMTimingInitStructure.FSMC_DataLatency = 0x00;
     FSMC_NORSRAMTimingInitStructure.FSMC_AccessMode = FSMC_AccessMode_A;     /* FSMC ·ÃÎÊģʽ */
     FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;       
     
     FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); 
     
     /* Enable FSMC Bank4_SRAM Bank */
     FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);  
}



Outcomes