Skip to main content
joesoftware
Associate III
Oct 31, 2012 7:26 PM UTC
Question

STM32vldiscovery and hd44780 display

Posted on October 31, 2012 at 20:26

Hi, i tried to use IAR example about LCD for use my display hd44780.

I connected 6 pin (RS,E,DB4,DB5,DB6,DB7) for use it on 4bit configuration (i'm sure that the connection is good cause i used that on my old arduino board).

I only see first line of black simple, nothing else.

Can someone help me with that code or link some other library that work good on stm32vldiscovery.

Thx
    This topic has been closed for replies.

    23 replies

    frankmeyer9
    Associate III
    Nov 2, 2012 9:57 AM UTC
    Posted on November 02, 2012 at 10:57

    I need i think a new rcc configuration and a new delay function, from 24MHZ and not from 72MHZ

     

    That is less critical IMHO.

    More important, the display starts up with a default configuration, which is, amongst others, 1 display line, display off, and 8-bit mode.

    I suggest to verify your driver code first, if you not yet did this.

    Single-step through the code that sets the control/data line, and verify all transitions and levels. A voltmeter suffices.

    crt2
    Visitor II
    Nov 2, 2012 11:05 AM UTC
    Posted on November 02, 2012 at 12:05

    I think idea is that your delay function is not ''exact'' enough. You should make it with TIMER interrupt which would be much more reliable as what you've posted (unless you do it in assembler code, I doubt you can predict how many cycles that for loop will have)

    void delay_ms(int ms)

    {

     long i, tms;

     tms = 9000*ms;

     for(i=0;i<tms;i++);

    }
    joesoftware
    Associate III
    Nov 7, 2012 5:05 PM UTC
    Posted on November 07, 2012 at 18:05

    I'm trying to do what u suggest, i have this function in main

    void Timer1IntrHandler (void)

    {

      // Clear update interrupt bit

      TIM_ClearITPendingBit(TIM1,TIM_FLAG_Update);

      Update = TRUE;

    }

    and this on stm32f10x_it.c

    void TIM1_UP_TIM16_IRQHandler(void)

    {

     Timer1IntrHandler();

    }

    But when i compile i have this warning:

    Warning[Pe223]: function ''Timer1IntrHandler'' declared implicitly

    Some idea to fix it?

    Tesla DeLorean
    Guru
    Nov 7, 2012 6:12 PM UTC
    Posted on November 07, 2012 at 19:12

    But when i compile i have this warning:

     

    Warning[Pe223]: function ''Timer1IntrHandler'' declared implicitly

     

    Some idea to fix it?

    Yes because you're referring to a function in a different file, you'll need to use a prototype.

    extern void Timer1IntrHandler(void);
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    joesoftware
    Associate III
    Nov 7, 2012 6:38 PM UTC
    Posted on November 07, 2012 at 19:38

    ok thanks

    orn
    Associate III
    Nov 8, 2012 2:26 PM UTC
    Posted on November 08, 2012 at 15:26

    I need a clarification!

    my driver for the LCD work well for 8-bit mode but works poorly for the 4-bit! there is nothing written on the datasheet for the 4-bit mode! I wanted to ask for your LCD as time allowed to pass between the first 4 bits

    and the second 4 bits?

    for example, the set function does not work well! what is wrong?

    void LCD_FS(void)

    {

    Delay(5);

    LCD_PORT->LOW= RS;  //RS  RESET

    LCD_PORT->LOW= RW;  //RW RESET

    // DB7  DB6  DB5  DB4  DB3  DB2  DB1  DB0  

    //   0        0       1        1       1       1        0     0

    //most significant bits

    LCD_PORT2->LOW =  DB7;

    LCD_PORT2->LOW =  DB6;

    LCD_PORT2->HIGH = DB5;

    LCD_PORT2->HIGH = DB4;

    LCD_En();

    //LB least significant bits

    LCD_PORT2->HIGH =  DB7;

    LCD_PORT2->HIGH =  DB6;

    LCD_PORT2->LOW= DB5;

    LCD_PORT2->LOW= DB4;

    LCD_En();

    }

    joesoftware
    Associate III
    Nov 9, 2012 7:05 PM UTC
    Posted on November 09, 2012 at 20:05

    Cause u need a delay imho before second section of command.

    Try with

    void LCD_FS(void)

    {

    Delay(5);

    LCD_PORT->LOW= RS; //RS RESET

    LCD_PORT->LOW= RW; //RW RESET

    // DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

    // 0 0 1 1 1 1 0 0

    //most significant bits

    LCD_PORT2->LOW = DB7;

    LCD_PORT2->LOW = DB6;

    LCD_PORT2->HIGH = DB5;

    LCD_PORT2->HIGH = DB4;

    LCD_En();

    //LB least significant bits

    Delay(50);

    LCD_PORT2->HIGH = DB7;

    LCD_PORT2->HIGH = DB6;

    LCD_PORT2->LOW= DB5;

    LCD_PORT2->LOW= DB4;

    LCD_En();

    }

    Verifty that u send enable pin UP when send command and low after u have send ur data ( i don't know if LCD_EN() do it, i just said to verify)

    orn
    Associate III
    Nov 9, 2012 9:00 PM UTC
    Posted on November 09, 2012 at 22:00

    I wait between sending the first and the second transmission, this is not the problem.

    I can also send the data, and bring up ''Hello word'' but I can not change the settings of the LCD for example, I do not accept the command to have two lines on the LCD or the command to clear the LCD ''LCD CLEAR'' etc etc. .... so there must be a problem in the code to send commands .... the code is this: /*MAIN*/

    LCD_Start4();
    LCD_PrintData4(Testo);

    //*LCD.C*//

    void LCD_Start(void){
    EnableGpioDLcd();
    EnableGpioELcd();
    Delay(30); //Wait for VDD
    LCD_command(0X3C); //Function set
    Delay(39);
    LCD_command(0X0C); //Display On Of
    Delay(39);
    LCD_command(0X01); //Clear
    Delay(2);
    LCD_command(0x06); //Mode Set
    Delay(30);
    LCD_command(0x02); //Home
    Delay(100);
    }
    void LCD_Init(void){
    Delay(15); //PRIMA RIPETIZIONE 
    LCD_PORT->LOW= RS; 
    LCD_PORT->LOW= RW; 
    LCD_command4(0x48);
    LCD_En();
    Delay(5); //SECONDA RIPETIZIONE
    LCD_PORT->LOW= RS; 
    LCD_PORT->LOW= RW; 
    LCD_command4(0x48);
    LCD_En();
    Delay(1); //TERZA RIPETIZIONE
    LCD_PORT->LOW= RS; 
    LCD_PORT->LOW= RW; 
    LCD_command4(0x48);
    LCD_En();
    }
    void LCD_command4(unsigned char Char){
    LCD_PORT->LOW=RS;
    Delay(10);
    if((Char&0x1)==0x1) 
    {
    LCD_PORT2->HIGH=DB4; 
    } 
    else
    {
    LCD_PORT2->LOW=DB4; 
    }
    if((Char&0x2)==0x2) 
    {
    LCD_PORT2->HIGH=DB5; 
    } 
    else
    {
    LCD_PORT2->LOW=DB5; 
    }
    if((Char&0x4)==0x4) 
    {
    LCD_PORT2->HIGH=DB6; 
    } 
    else
    {
    LCD_PORT2->LOW=DB6; 
    }
    if((Char&0x8)==0x8) 
    {
    LCD_PORT2->HIGH=DB7; 
    } 
    else
    {
    LCD_PORT2->LOW=DB7; 
    }
    LCD_En();
    Delay(100);
    }
    void LCD_Write4(unsigned char Char){
    LCD_PORT->HIGH=RS;
    Delay(10); 
    if((Char&0x1)==0x1) 
    {
    LCD_PORT2->HIGH=DB4; 
    } 
    else
    {
    LCD_PORT2->LOW=DB4; 
    }
    if((Char&0x2)==0x2) 
    {
    LCD_PORT2->HIGH=DB5; 
    } 
    else
    {
    LCD_PORT2->LOW=DB5; 
    }
    if((Char&0x4)==0x4) 
    {
    LCD_PORT2->HIGH=DB6; 
    } 
    else
    {
    LCD_PORT2->LOW=DB6; 
    }
    if((Char&0x8)==0x8) 
    {
    LCD_PORT2->HIGH=DB7; 
    } 
    else
    {
    LCD_PORT2->LOW=DB7; 
    }
    LCD_En();
    } 
    void LCD_PrintData4(unsigned char Vet[]){
    int i=9;
    for(i=0;i<
    9
    ;i++){
    LCD_Write4((Vet[i]>>4)&0x0F);
    Delay(10);
    LCD_Write4((Vet[i]&0x0F));
    }
    }
    void LCD_Start4(void){
    EnableGpioDLcd();
    EnableGpioELcd();
    LCD_PORT->LOW = DB3;
    LCD_PORT->LOW = DB2; 
    LCD_PORT->LOW = DB1; 
    LCD_PORT->LOW = DB0; 
    LCD_Init();
    Delay(15); //Wait for VDD
    LCD_command4((0X3C>>4)&0x0F); //Function set
    LCD_command4(0X3C&0x0F);
    Delay(39);
    LCD_command4((0X0C>>4)&0x0F); //Display On Of
    LCD_command4(0X0C&0x0F);
    Delay(39);
    LCD_command4((0X01>>4)&0x0F); //Clear
    LCD_command4(0X01&0x0F);
    Delay(10);
    LCD_command4((0X06>>4)&0x0F); //Mode Set
    LCD_command4(0X06&0x0F);
    Delay(30);
    LCD_command4((0X02>>4)&0x0F); //Mode Set
    LCD_command4(0X02&0x0F);
    Delay(100);
    }

    orn
    Associate III
    Nov 9, 2012 9:03 PM UTC
    Posted on November 09, 2012 at 22:03

    unsigned char Testo[9]={'T','e','s','t','o',':','-',')',' '};

    joesoftware
    Associate III
    Nov 11, 2012 6:24 PM UTC
    Posted on November 11, 2012 at 19:24

    I just can link u this

    http://joshuagalloway.com/lcd.html

    , i see that some value is different from ur project, i hope it is helpful for u.