[solved] lcd with stm.

Status
Not open for further replies.

Thread Starter

ABHI1892

Joined Jun 23, 2017
6
Hello , I'm trying to interface a 16x1 lcd with the stm8. My code is as follows:
(I'm using the 16MHz internal clock)
C:
# include "stm8l.h"
# include "stm8s.h"

void lcdinit(void)
{
    LCD_CR1 = 0x06;
    LCD_CR2 = 0xEE;
    LCD_FRQ = 0X30;
    LCD_PM0 = 0x92;
    LCD_PM1 = 0x00;
    LCD_PM2 = 0xB0;
    LCD_PM3 = 0x04;
    LCD_RAM0 = 0xFF;
    LCD_RAM1 = 0xFF;
    LCD_RAM2 = 0xFF;
    LCD_RAM3 = 0xFF;
    LCD_RAM4 = 0xFF;
    LCD_RAM5 = 0xFF;
    LCD_RAM6 = 0xFF;
    LCD_RAM7 = 0xFF;
    LCD_RAM8 = 0xFF;
    LCD_RAM9 = 0xFF;
    LCD_RAM10 = 0xFF;
    LCD_RAM11 = 0xFF;
    LCD_RAM12 = 0xFF;
    LCD_RAM13 = 0xFF;
    LCD_CR3 = 0x40;
    PB_DDR = 0x10;
    PB_CR1 = 0x10;
}
After this initialization , I'm not getting how to send string data to display on the lcd. Where should i write the data to get the display on lcd.

Thanks.
 
Last edited by a moderator:

MrChips

Joined Oct 2, 2009
34,810
Hello , I'm trying to interface a 16x1 lcd with the stm8. My code is as follows:
(I'm using the 16MHz internal clock)
# include "stm8l.h"
# include "stm8s.h"

void lcdinit(void)
{
LCD_CR1 = 0x06;
LCD_CR2 = 0xEE;
LCD_FRQ = 0X30;
LCD_PM0 = 0x92;
LCD_PM1 = 0x00;
LCD_PM2 = 0xB0;
LCD_PM3 = 0x04;
LCD_RAM0 = 0xFF;
LCD_RAM1 = 0xFF;
LCD_RAM2 = 0xFF;
LCD_RAM3 = 0xFF;
LCD_RAM4 = 0xFF;
LCD_RAM5 = 0xFF;
LCD_RAM6 = 0xFF;
LCD_RAM7 = 0xFF;
LCD_RAM8 = 0xFF;
LCD_RAM9 = 0xFF;
LCD_RAM10 = 0xFF;
LCD_RAM11 = 0xFF;
LCD_RAM12 = 0xFF;
LCD_RAM13 = 0xFF;
LCD_CR3 = 0x40;
PB_DDR = 0x10;
PB_CR1 = 0x10;
}
After this initialization , I'm not getting how to send string data to display on the lcd. Where should i write the data to get the display on lcd.

Thanks.
What are all those variables, LCD_CR1, etc.?
Where are these declared?

Your code is meaningless without a hardware schematic diagram.
 

JohnInTX

Joined Jun 26, 2012
4,787
Not wrong if that is what you want. The raw LCD glass backplanes and segments get driven by the stm itself. Each segment maps to one bit of an LCD_RAMxx register. Setting the bit turns on the segment. Which bit turns on which segment is entirely determined by how you connect the display to the uC, segments can be scattered over the RAM array. You'll need a generate a bit-to-segment map.
Since there is no decoder you need to write one for each digit that generates the segment pattern for a digit. For example, segments b and c make up a '1' display. To display that '1' you'll need to set two bits in the LED_RAM array as determined by your segment map. Displaying a '1' on another digit requires that you set two different bits in LCD_RAM.

Displaying a string will require several levels of processing to decode the characters into segment patterns for each digit then flip bits on and off to assign those logical segments to the physical display.
Good luck.
 

Thread Starter

ABHI1892

Joined Jun 23, 2017
6
Not wrong if that is what you want. The raw LCD glass backplanes and segments get driven by the stm itself. Each segment maps to one bit of an LCD_RAMxx register. Setting the bit turns on the segment. Which bit turns on which segment is entirely determined by how you connect the display to the uC, segments can be scattered over the RAM array. You'll need a generate a bit-to-segment map.
Since there is no decoder you need to write one for each digit that generates the segment pattern for a digit. For example, segments b and c make up a '1' display. To display that '1' you'll need to set two bits in the LED_RAM array as determined by your segment map. Displaying a '1' on another digit requires that you set two different bits in LCD_RAM.

Displaying a string will require several levels of processing to decode the characters into segment patterns for each digit then flip bits on and off to assign those logical segments to the physical display.
Good luck.
Thank you John for your advice. Could you please tell me what a COM port in a lcd is? What is its function? And will simply writing '1' in the LCD_RAM register not help? Because when I tried doing it and deugging , I found that the RAM registers stored the corresponding ASCII values properly. Only thing is that I could not get it on the display.
 

JohnInTX

Joined Jun 26, 2012
4,787
I don't think we are talking about the same thing. What is the part number of the display? Can you post a link to its datasheet and a schematic showing how you hooked it up?

EDIT: There is no COM port on a bare-glass LCD. Some bare-glass LCD datasheets refer to the backplane of the LCD as COM(mon). Many of those can use several backplanes (COMs) to multiplex the segments (more segments with fewer wires).

In any case, you can't just drop an ASCII character, or binary or hex for that matter, into one of the LCD_RAM registers and get it to display anything meaningful. You have some decoding to do.

So, most important, are you using a bare LCD glass i.e. no PC board and no controller chip?
Let us know what you are working with, with part numbers and links to datasheets please - including the microcontroller, and we'll go from there. It's not hard but the approaches are completely dependent on the display type.
 
Last edited:

Thread Starter

ABHI1892

Joined Jun 23, 2017
6
I don't think we are talking about the same thing. What is the part number of the display? Can you post a link to its datasheet and a schematic showing how you hooked it up?

EDIT: There is no COM port on a bare-glass LCD. Some bare-glass LCD datasheets refer to the backplane of the LCD as COM(mon). Many of those can use several backplanes (COMs) to multiplex the segments (more segments with fewer wires).

In any case, you can't just drop an ASCII character, or binary or hex for that matter, into one of the LCD_RAM registers and get it to display anything meaningful. You have some decoding to do.

So, most important, are you using a bare LCD glass i.e. no PC board and no controller chip?
Let us know what you are working with, with part numbers and links to datasheets please - including the microcontroller, and we'll go from there. It's not hard but the approaches are completely dependent on the display type.
I'm using the GDM0801 lcd module with the stm8l152c8 microcontroller. The schematic is as follows:
 

Attachments

Status
Not open for further replies.
Top