cancel
Showing results for 
Search instead for 
Did you mean: 

Character LCD ( Help !)

leventeyigel52
Associate II
Posted on January 17, 2012 at 16:34

Hi,

I'm using STM32 F103 microcontroller and 2x16 character lcd.I want to  display strings on it.(HD 44780 driver)

I'm new on ARM microcontrollers and i couldn't find a demo project for this lcd.

Who can help me about it ?

Is there any demo project  in this site ? Can you give me a link or adress ?

#character-lcd
12 REPLIES 12
rosarium
Associate II
Posted on January 17, 2012 at 18:06

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6aj&d=%2Fa%2F0X0000000brJ%2F7Q8829FdWhPciWBM5aB58hz_1XLrryJcGhQPMbrdn08&asPdf=false
rosarium
Associate II
Posted on January 17, 2012 at 18:11

Now this is header file to the last source file.

//------------------------------------------------------------

/* Includes ------------------------------------------------------------------*/

#include ''stm32f10x_type.h''

#include ''stm32f10x_gpio.h''

/* Macro Definitions ---------------------------------------------------------*/

#define SET_RS            (GPIO_WriteBit(GPIOC, GPIO_Pin_2, Bit_SET));

#define RESET_RS          (GPIO_WriteBit(GPIOC, GPIO_Pin_2, Bit_RESET));

#define SET_ENABLE        (GPIO_WriteBit(GPIOC, GPIO_Pin_10, Bit_SET));

#define RESET_ENABLE      (GPIO_WriteBit(GPIOC, GPIO_Pin_10, Bit_RESET));

/* private define-------------------------------------------------------------*/

#define LINEONE           (1)// line one of 16X2 alphanumeric display

#define LINETWO           (2)// line two of 16X2 alphanumeric display

#define LINETWO_HOME      (0xc0)

#define LINEONE_HOME      (0x80)

#define START_ONE         (0x33)

#define START_TWO         (0x32)

#define FUNCTION_SET      (0x38)

#define DISPLAY_OFF       (0x08)

#define DISPLAY_SETTINGS  (0x0E)

#define ENTRY_MODESET     (0x06)

#define CLR_DISPLAY       (0x01)

#define RETURN_HOME       (0x02)

#define MS_FIVE           (0x0032)

#define MS_FIFTEEN        (0x0096)

#define MS_EIGHTY         (0x0320)

#define VH_OnTime         (0x0015)

#define VH_OffTime        (0x0004)

#define FIVE_SEC          (0xC350)

#define MS_ONE            (0x000A)

#define ONE_SEC           (0x2710)

#define TWO_SEC           (0x4E20)

#define TEN_MILLI_SEC     (0x0064)

#define MS_P19            (0x0019)

/*data line defination--------------------------------------------------------*/

#define DATA_LINE_0       (0x0001)

#define DATA_LINE_1       (0x0002)

#define DATA_LINE_2       (0x0004)

#define DATA_LINE_3       (0x0008)

#define DATA_LINE_4       (0x0010)

#define DATA_LINE_5       (0x0020)

#define DATA_LINE_6       (0x0040)

#define DATA_LINE_7       (0x0080)

/* Exported functions ------------------------------------------------------- */

/* LCD functions */

void LCD_Init(void);

void ClrDisplay(void);

void WriteCommand(u8);

void WriteData(u8);

void ChangeLine(u8);

void WriteString(u8 *);

void Delay(u32);

//------------------------------------------------------------

leventeyigel52
Associate II
Posted on January 17, 2012 at 21:55

That it is,I hope this work properly ! 

Thanks alot rosarium.... (:

rosarium
Associate II
Posted on January 18, 2012 at 07:22

You are welcome... :)

Yes it works alright.

leventeyigel52
Associate II
Posted on January 18, 2012 at 09:15

Can you or another people give me the pin assigments 

''C:\Program Files\IAR Systems\Embedded Workbench 6.0\arm\examples\ST\STM32F10x\IAR-STM32-SK\LCD_Demo''

this program ?

This project is working properly but im not sure connecting  the LCD to true pins.

What is the DB4~DB7 pin assigments ? I couldn't find on the project file ..

rosarium
Associate II
Posted on January 18, 2012 at 18:30

Now which example is this you are talking about??

Is this for the same LCD (16 x 2)???

Posted on January 18, 2012 at 18:54

Can you or another people give me the pin assigments

''C:\Program Files\IAR Systems\Embedded Workbench 6.0\arm\examples\ST\STM32F10x\IAR-STM32-SK\LCD_Demo''

this program ? You could determine this by inspecting the source code, or a schematic for the IAR-STM32-SK board. The Data pins are PC.0 .. PC.3 From examples\ST\STM32F10x\IAR-STM32-SK\LCD_Demo\modules\drv_hd44780_l.h

#define LCD_LIGHT GPIO_Pin_0
#define LCD_LIGHT_PORT GPIOB
#define LCD_RS GPIO_Pin_8
#define LCD_RS_PORT GPIOC
#define LCD_E GPIO_Pin_12
#define LCD_E_PORT GPIOC
#define LCD_RW GPIO_Pin_9
#define LCD_RW_PORT GPIOC
#define LCD_DATA 0x0FUL
#define LCD_DATA_SHIFT 0
#define LCD_DATA_PORT GPIOC
#define LCD_LIGHT_ON() GPIO_WriteBit(LCD_LIGHT_PORT,LCD_LIGHT,Bit_SET)
#define LCD_LIGHT_OFF() GPIO_WriteBit(LCD_LIGHT_PORT,LCD_LIGHT,Bit_RESET)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
joesoftware
Associate II
Posted on November 07, 2012 at 18:40

If i have databit on GPIOB 10,11,12,13 can i modify

#define LCD_DATA         GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13

#define LCD_DATA_SHIFT            0

#define LCD_DATA_PORT             GPIOB

Is that correct? if not how can i modify this for use that 4 pin?

Posted on November 07, 2012 at 21:05

You'd presumably want a shift of 10 to get the bits aligned properly for output on the GPIO port/bus.

#define LCD_DATA_SHIFT 10

#define LCD_DATA         (GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13)

#define LCD_DATA_PORT             GPIOB

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..