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-17 04:09 AM
Hi
The problem is I'm a beginner so I try to do with wat I understand.
I took a working library for the same hardware but 16x2LCD instead and adapted it to 20x4 LCDI already id the same previously with STD periph lib and no I2C communication and it worked well
Now this is with I2C and HAL.
As of today here is the better result I have:
Parameters:
♯ define SLAVE_ADDRESS_LCD 0x4E
♯ define LCD_SET_DDRAM_ADDRESS 0x80
void lcd_init (void)
{ lcd_send_cmd (0x02); lcd_send_cmd (0x28); lcd_send_cmd (0x0c); lcd_send_cmd (LCD_SET_DDRAM_ADDRESS);}Code sent:
lcd_send_string ('12345678912345678910');
lcd_send_string ('123');On the diplay I have:
12345678912345678910 on the first row and 123 on the third row.
When i use goto and other function, it's a mess.
For what I know, the ddram address seems to be 0x80
But I don't understand the init function, this is why I didn't touch the following commands:
lcd_send_cmd (0x02);
lcd_send_cmd (0x28);
lcd_send_cmd (0x0c);
It was working great for 16x2 with these commands but not with 20x4
Thank you once again for your help
2018-05-18 04:00 AM
If continuous writing writes to lines 1 and 3, it's probably the usual arrangement, i.e. 1st+3rd line for one logical line, and so do 2nd+4th line which are offset by 0x40
As I've said, keep on writing. The 64th (0x40th) character should appear on line 4.
Note, that the goto routine above assumes 0-based coordinates, i.e. 1st line is y=0; y=2 is 3rd line.
JW
2018-05-24 05:06 AM
look into my libraries, you might find something useful
________________ Attachments : ll_library.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxXz&d=%2Fa%2F0X0000000azx%2FB4DQcXflIPB_CQTjclH5PgJkFOWRBoSJSvQAojT2FCU&asPdf=false2018-05-24 03:42 PM
Hi
For what I understand there is a difference here:
my code:
// Number of visible lines of the display (1 or 2/4)
&sharpdefine LCD_LINES 4// Visible characters per line of the display&sharpdefine LCD_DISP_LENGTH 20// DDRAM address of first char of line 1&sharpdefine LCD_START_LINE_1 0x00// DDRAM address of first char of line 2&sharpdefine LCD_START_LINE_2 0x40// DDRAM address of first char of line 3&sharpdefine LCD_START_LINE_3 0x14// DDRAM address of first char of line 4&sharpdefine LCD_START_LINE_4 0x54and you code:
if (line < LCD_NR_LINES) {
if (line == 0) return 0x00; else if (line == 1) return 0x40; else if (line == 2) return 0x00 + LCD_NR_CHARS; else if (line == 3) return 0x40 + LCD_NR_CHARS;with
LCD_NR_CHARS:
&sharpdefine LCD_NR_CHARS 20
but the result is also 0x14
2019-01-18 04:21 AM
Hello,
it seams this task is quite a long time in process. Did you manage to get it running? I'm looking for the exact same.
2020-04-26 12:54 PM
Hi,
if you are still interested I am working on an I2C LCD (PCF5874T + HD44780) library for STM32F1x. It's still WIP, but you can check it out
https://github.com/meteowrite/stm32_i2cLcd
Cheers,
-
2020-11-11 06:31 AM
Hey there,
in the past I've worked with the same LCD+I2C combination. You may check it out on github, see if it helps:
https://github.com/meteowrite/stm32_i2cLcd
Br,
Dimitar