cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152 LCD driver

moran
Associate II
Posted on April 16, 2015 at 10:00

Hello,

I'm working on a custom board STM32l152 that include LCD (1/4 duty & 1/3 bias)

I just want to enable all signal ( 64  =  16 * 4Com ) in order to check the screen.

somehow only 1 (of 4) raw is working.

 

this is my code :

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*!< Enable GPIOA, GPIOB, GPIOC AHB Clocks */

      RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC, ENABLE);

      //Segments 0 - 4

      GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_LCD);

     

      //Segments 5 - 6

      GPIO_PinAFConfig(GPIOC, GPIO_PinSource4, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_LCD);

     

           

      //Segments 7 - 8

      GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_LCD);

     

       //Segments 9 - 12

      GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_LCD);

      

     

      //Segments 13 - 15

      GPIO_PinAFConfig(GPIOB, GPIO_PinSource14, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOB, GPIO_PinSource13, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_LCD);

     

      //COM 0-3

      GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOA, GPIO_PinSource10,GPIO_AF_LCD);

      GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_LCD);

     

      a_opLcdControl->m_iLcdGPIO.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_6 |

                                            GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;

      a_opLcdControl->m_iLcdGPIO.GPIO_Speed = GPIO_Speed_40MHz;

      a_opLcdControl->m_iLcdGPIO.GPIO_Mode = GPIO_Mode_AF;

      a_opLcdControl->m_iLcdGPIO.GPIO_OType = GPIO_OType_PP;

      a_opLcdControl->m_iLcdGPIO.GPIO_PuPd = GPIO_PuPd_NOPULL;

      GPIO_Init(GPIOA, &a_opLcdControl->m_iLcdGPIO);

      a_opLcdControl->m_iLcdGPIO.GPIO_Pin = GPIO_Pin_0  | GPIO_Pin_1  |  GPIO_Pin_9 |

                                            GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;

      GPIO_Init(GPIOB, &a_opLcdControl->m_iLcdGPIO);

      a_opLcdControl->m_iLcdGPIO.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 |

                                            GPIO_Pin_8 | GPIO_Pin_9;

      GPIO_Init(GPIOC, &a_opLcdControl->m_iLcdGPIO);

     // LCD_GPIOConfig(); /*!< Configure the LCD Glass GPIO pins */

      /*!< Configure the LCD interface -------------------------------------------*/

      RCC_APB1PeriphClockCmd(RCC_APB1Periph_LCD, ENABLE); /*!< Enable LCD APB1 Clock */

     

      a_opLcdControl->m_iLcdInit.LCD_Prescaler = LCD_Prescaler_8;//LCD_Prescaler_8;

      a_opLcdControl->m_iLcdInit.LCD_Divider = LCD_Divider_16;

      a_opLcdControl->m_iLcdInit.LCD_Duty = LCD_Duty_1_4;

      a_opLcdControl->m_iLcdInit.LCD_Bias = LCD_Bias_1_3;

      a_opLcdControl->m_iLcdInit.LCD_VoltageSource = LCD_VoltageSource_Internal;//LCD_VoltageSource_External;//LCD_VoltageSource_Internal;

      LCD_Init(&a_opLcdControl->m_iLcdInit);

      /*!< Configure the Pulse On Duration */

      LCD_PulseOnDurationConfig(LCD_PulseOnDuration_2);

     

      /*!< Configure the LCD Contrast (3.51V) */

      LCD_ContrastConfig(LCD_Contrast_Level_7);

      /*!< Wait Until the LCD FCR register is synchronized */

      LCD_WaitForSynchro();

     

      /*!< Enable LCD peripheral */

      LCD_Cmd(ENABLE);

     

      /*!< Wait Until the LCD is enabled */

      while(LCD_GetFlagStatus(LCD_FLAG_ENS) == RESET)

      {

      }

      /*!< Wait Until the LCD Booster is ready */ 

      while(LCD_GetFlagStatus(LCD_FLAG_RDY) == RESET)

      {

      }   

LCD_Write(LCD_RAMRegister_0, 0xffffffff);

LCD_UpdateDisplayRequest();     

     

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Please advise, what wrong ?

Thanks,

Moran.

2 REPLIES 2
stm322399
Senior
Posted on April 16, 2015 at 10:35

Did you try to write other LCD RAM registers, I see only a single of them accessed from your code ?

--

Laurent

moran
Associate II
Posted on April 16, 2015 at 16:10

Thanks Laurent,

You right.

In order to operate all 4 COMs i have to write :

LCD_Write(LCD_RAMRegister_0, 0xffffffff);

LCD_Write(LCD_RAMRegister_2, 0xffffffff);

LCD_Write(LCD_RAMRegister_4, 0xffffffff);

LCD_Write(LCD_RAMRegister_6, 0xffffffff);

Thanks.