This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

lcd project at stm32

Hi, I'm new in embedded system,I've stm32f100rb and I want to display a string at an lcd named jhd162a 16x2, but when I test it, the lcd always display a black line,I test it with an empty board and it's the same problem, one black line.
anyone have an idea please???
and thank you.

Parents Reply Children
  • this is my init function:

     void lcd_init(void)
    {
      volatile unsigned char i = 0;
      volatile unsigned int delayCnt = 0;
            RCC_APB2PeriphClockCmd(LCD_CLK_LINE, ENABLE);
      GPIO_InitStructure.GPIO_Pin = LCD_D4|LCD_D5|LCD_D6|LCD_D7|LCD_RS|LCD_RW|LCD_EN;
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    
      GPIO_Init(LCD_GPIO, &GPIO_InitStructure);
    
      GPIO_ResetBits(LCD_GPIO, LCD_RS | LCD_EN | LCD_RW);
    
      for(delayCnt = 0; delayCnt < 300000; delayCnt++);
    
      for(i = 0; i < 3; i++) {
        lcd_writenibble(0x03);
        for(delayCnt = 0; delayCnt < 30000; delayCnt++);
      }
    
      lcd_writenibble(0x02);
    
      for(delayCnt = 0; delayCnt < 6000; delayCnt++);
    
      lcd_writecommand(HD44780_FUNCTION_SET |
                       HD44780_FONT5x7 |
                       HD44780_TWO_LINE |
                       HD44780_4_BIT);
    
      lcd_writecommand(HD44780_DISPLAY_ONOFF |
                       HD44780_DISPLAY_OFF);
    
      lcd_writecommand(HD44780_CLEAR);
    
      lcd_writecommand(HD44780_ENTRY_MODE |
                       HD44780_EM_SHIFT_CURSOR |
                       HD44780_EM_INCREMENT);
    
      lcd_writecommand(HD44780_DISPLAY_ONOFF |
                       HD44780_DISPLAY_ON |
                       HD44780_CURSOR_OFF |
                       HD44780_CURSOR_NOBLINK);
    
    }