2018-04-30 09:29 PM
Good morning,
I'm beginner with STM but managed to get working a STM32F103 LCD16x2 using i2C
Now, I would like to use i2C but with 20x4 LCD, nothing fancy
I modified the library according to what I was thinking correct but I can't get it working properly.
I used this tutorial for the 16x2 lcd:
http://controllerstech.com/i2c-lcd-in-stm32/
because I use this i2C module:
PCF8574
And the LCD screen 20x4:
I have weird characters wrote on the LCD but not at the good position and not what it's supposed to be displayed
The project is attached
Do you have any idea of what I did wrong ?
Thank you
#lcd-display #i2c #stm32f1032018-05-01 01:04 AM
Observe, what's on the LCD pins, by a logic analyzer, and compare that to HD44780 datasheet.
JW
2018-05-03 03:48 AM
Unfortunately I don't know how to do that...
I changed the I2C address for 0x27 which seems to be the correct one when A1, A2 and A3 are low, but not working either
2018-05-03 04:03 AM
Easy.
1. Read the LCD datasheet and see how it works. Sending data to four lines is just starting at different addresses.
2. Read the i2c expanders datasheet and schematic to see how to send the commands
3. Done.
Cannot be simpler than that.
2018-05-16 05:36 AM
Good afternoon,
I made some progress:
Use slave address 0x27<<1 diplay the correct first row
But when i'm supposed to display to the following row, nothing.
Idon't understand because I use common display and I2C odule, this is strange.
Here is the whole project
https://drive.google.com/open?id=1gIY039_RFFDAfFDW0_sDU0ZDy4AEFY8E
Any help is appreciated
Thank you
2018-05-16 07:50 AM
not sure exactly, but
some displays will display the 21st character on the next line
and other displays need a CR to go the 2nd line.
its in the datasheet.
what page are you reading ?
send us the link to the data sheet.
2018-05-16 07:52 AM
Hi
I think this is the correct datasheet:
2018-05-16 07:56 AM
Figure 6 in the datasheet, shows the address of the first character on the second line is 40.
A CR will probably do it.
2018-05-16 08:04 AM
What is a CR?
Because I tried to write on line 2:
&sharpdefine LCD_START_LINE_2 0x40
void lcd_gotoxy(uint8_t x, uint8_t y)
{&sharpif LCD_LINES == 1
lcd_send_cmd(LCD_SET_DDRAM_ADDRESS | (LCD_START_LINE_1 + x));&sharpelif LCD_LINES == 2 if (y == 0) lcd_send_cmd(LCD_SET_DDRAM_ADDRESS | (LCD_START_LINE_1 + x)); else lcd_send_cmd(LCD_SET_DDRAM_ADDRESS | (LCD_START_LINE_2 + x));&sharpelif LCD_LINES == 4 if (y == 0) lcd_send_cmd(LCD_SET_DDRAM_ADDRESS | (LCD_START_LINE_1 + x)); else if (y == 1) lcd_send_cmd(LCD_SET_DDRAM_ADDRESS | (LCD_START_LINE_2 + x)); else if (y == 2) lcd_send_cmd(LCD_SET_DDRAM_ADDRESS | (LCD_START_LINE_3 + x)); else lcd_send_cmd(LCD_SET_DDRAM_ADDRESS | (LCD_START_LINE_4 + x));&sharpendif}but not working:
lcd_gotoxy(0,0); //
lcd_send_string ('subscribe'); lcd_gotoxy(0,2); lcd_send_string ('to this channel');this print nothing
2018-05-16 02:38 PM
Just write characters consecutively, without using any 'goto', maybe with small delay between each character so you see how they appear up consecutively. They should start to show up in next lines - maybe not consecutively, most probably like 1-3-2-4. There may be a delay between the lines.
This should reveal you the 'structure'/adressing of the module itself. They can be built in several ways so there's no 'good recipe' unless you have datasheet for the particular make of the module (which I presume you don't have).
If you can display only on 2 lines using this method, you haven't properly initialized the module (i.e. you need to put it into the 1/16 duty mode).
JW