Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good morning,
I am doing a project for my school, for this I have to communicate with an LCD screen 2x16 (I2C). I use CubeIDE software and NUCLEO-STM32F411RE development board. I have already my program, there is no error or warning. however the screen is on and nothing is displayed. I was first advised to add pull up resistors which I did. no changes. To be sure it's not a programming problem, I flash the LED integrated into the card (just after the LCD screen should display something.) The LED flashes as expected. The last hypothesis would be a bad communication with the LCD screen. Do you know how to invalidate or not this hypothesis? or even solve it? Or do you think this is another problem?

I use this code to begin : Interfacing STM32 with I2C LCD : HAL example code included[^]

THANKS :)

What I have tried:

lcd_init1();
  lcd_backlight(1); // Turn on backlight


  lcd_clear_display();
  lcd_home();


    char *text = "EmbeddedThere";
    char int_to_str[10];
    int count=0;

    while (1)
    {
  	  sprintf(int_to_str, "%d", count);
  	  lcd_clear();
  	  lcd_set_cursor(0, 0);
  	  lcd_write_string(text);
  	  lcd_set_cursor(1, 0);
  	  lcd_write_string(int_to_str);
  	  count++;

  	if((count>0)&&(count<10))
  	  	  {
  				HAL_GPIO_WritePin(GPIOA,LD2_Pin,1);
  				HAL_Delay(100);
  				HAL_GPIO_WritePin(GPIOA,LD2_Pin,0);
  				HAL_Delay(100);
  	  	  }

  	  memset(int_to_str, 0, sizeof(int_to_str));
  	  HAL_Delay(1500);

    }
  }
Posted
Updated 25-Apr-23 20:23pm

I would go back to the site you found the code on, and ask there - they will at least n=know what the processor board is expecting to be connected to it, and how.
They may even have used the same LCD and have a good idea of it's interface requirements.

Generally speaking, you can't expect code written for one specific board and one specific LCD to work unchanged on a different board and / or a different display: you need to look at the specifics of how they are connected and what "language" they both expect the other to speak! Think of learning to drive an automatic car and assuming you can drive a manual in the same way ... it's just not goign to work without changes ...

And this is a "general software " site - you need to talk to much more specific people such as those at the site you found the code on. Good luck!
 
Share this answer
 
For things at this site, have a look at this person's articles : code-witch Articles[^]. Scroll down a bit for articles on this topic.
 
Share this answer
 
Check the hardware connections (if you have a logical analyzer, or an oscilloscope, then check the I2C signals as well). Then try to run the sample code as it stands. If it works then start to adapt it to your needs.
 
Share this answer
 
First, you would be better served by asking your question in a forum dedicated to the hardware you're using, at ST Community[^].

Next, you make no mention of what pins you connected the LCD on, which LCD it is, what it's requirements are, and there is nothing in the code you posted that shows where you tell the code what pins are for what on the LCD module.

Without that, you're not talking to the LCD. You're just throwing data into nothing.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900