Custom Character Display Using LPC2148

This article is a continuation of the series of tutorials on the LPC2148 Microcontroller (ARM7). The aim of this series is to provide easy and practical examples that anyone can understand. In the previous tutorial, we have interfaced the LCD 8-bit with LPC2148 (ARM7). In this tutorial, we are going to see how to generate LCD Custom Character (Custom Character Display Using LPC2148).

Prerequisites

Before starting this tutorial we should know the below topics. If you know already, please go further.

How to generate LCD Custom Character using LPC2148

Introduction

So we know how to display alphanumeric characters in LCD. We can easily display that. Because it is already stored in the ROM memory of LCD. Before that, we should know the memories of LCD. There are three types of memory present in the LCD display.

  1. CG ROM
  2. DD RAM
  3. CG RAM

CG ROM (Character Generator ROM) 

This memory holds the pattern for every single character of predefined LCD font. and you call the content of this memory by the placing corresponding ASCII value on the LCD port. For example, if you want to display  ‘A’ you have to send the ASCII value of ‘A’ which is 0x41 to the LCD.   So we cannot modify its contents which are stored already.

DD RAM  (Display Data RAM)

DDRAM is the memory that holds only those characters who are currently on the screen. This means if there is a message is currently being displayed on the screen then it has to be on the DDRAM. For example, if you want to display “hello” on the screen then you have to load the pattern of h from the CG ROM to DD RAM then do the same for ‘e’ ,’l’ ,’l’ and ‘o’.

This is the address of the DDRAM memory in 16×2 LCD

Position1234.....16
Row1 0x800X810X820X83......0X8F
Row20xC00XC10XC20XC3......0XCF

This memory works the same as CG ROM but as this is RAM we can modify its content at any time. So this is the place where we can store our custom character pattern. Then that pattern can be sent to display.

CG RAM (Character generator RAM)

For making custom patterns we need to write values to the CGRAM area defining which pixel to glow. These values are to be written in the CGRAM address starting from 0x40. Bit 7 is 0 and Bit 6 is 1, due to which the CGRAM address command starts from 0x40, where the address of CGRAM (Acg) starts from 0x00. CGRAM has a total of 64 Bytes. When you are using LCD as 5×8 dots in the function set then you can define a total of 8 user-defined patterns (1 Byte for each row and 8 rows for each pattern), whereas when LCD is working in 5×10 dots, you can define 4 user-defined patterns.

Custom Character Display Using LPC2148

Connection

LCD

  • RS – P0.8
  • RW – P0.9
  • EN – P0.10
  • Data Lines – P0.0 – P0.7

Source Code

This code will print the custom character in the Tamil language. The Tamil language is not in the LCD. So that I’m going to create a few characters from Tamil. You can also try in your language or any custom character you want. See the code attached below.

#include<lpc214x.h>
#define bit(x) (1<<x)
#define delay for(i=0;i<3000;i++);

unsigned int i;

void lcd_int();
void dat(unsigned char);
void cmd(unsigned char);
void string(unsigned char *);
void store();

void main()
{
    IO0DIR|=0XFFF;
    lcd_int();
    store();              //Storing the custom characters
    while(1) {
        cmd(0x1c);        //Scroll command
        cmd(0x80);        //Location
        dat(0);
        dat(1);
        dat(2);
    }
}

void lcd_int()
{
    cmd(0x30);
    cmd(0x0c);
    cmd(0x06);
    cmd(0x01);
    cmd(0x80);
}

void cmd(unsigned char a)
{
    IO0PIN&=0x00;
    IO0PIN|=(a<<0);
    IO0CLR|=bit(8);                //rs=0
    IO0CLR|=bit(9);                //rw=0
    IO0SET|=bit(10);               //en=1
    delay;
    IO0CLR|=bit(10);               //en=0
}

void dat(unsigned char b)
{
    IO0PIN&=0x00;
    IO0PIN|=(b<<0);
    IO0SET|=bit(8);                //rs=1
    IO0CLR|=bit(9);                //rw=0
    IO0SET|=bit(10);               //en=1
    delay;
    IO0CLR|=bit(10);               //en=0
}

void string(unsigned char *p)
{
    while(*p!='\0')
    {
        dat(*p++);
    }
}

void store()
{
    cmd(64);          //First location
    dat(31);
    dat(20);
    dat(31);
    dat(21);
    dat(29);
    dat(1);
    dat(15);
    dat(0);
 
    cmd(72);          //Second location
    dat(1);
    dat(2);
    dat(2);
    dat(23);
    dat(21);
    dat(21);
    dat(31);
    dat(0);
 
    cmd(80);            //Third location
    dat(4);
    dat(0);
    dat(23);
    dat(21);
    dat(31);
    dat(4);
    dat(28);
    dat(0);
}

Output

Custom Character Display Using LPC2148[ Please find the output image Here ]

In our next tutorial, we will see how to interface the LCD in 4-bit mode with LPC2148 (ARM7). If you want to use FreeRTOS on LPC2148, then please refer FreeRTOS series.

You can also read the below tutorials.

Linux Device Driver TutorialsC Programming Tutorials
FreeRTOS TutorialsNuttX RTOS Tutorials
RTX RTOS TutorialsInterrupts Basics
I2C Protocol – Part 1 (Basics)I2C Protocol – Part 2 (Advanced Topics)
STM32 TutorialsLPC2148 (ARM7) Tutorials
PIC16F877A Tutorials8051 Tutorials
Unit Testing in C TutorialsESP32-IDF Tutorials
Raspberry Pi TutorialsEmbedded Interview Topics
Reset Sequence in ARM Cortex-M4BLE Basics
VIC and NVIC in ARMSPI – Serial Peripheral Interface Protocol
STM32F7 Bootloader TutorialsRaspberry PI Pico Tutorials
STM32F103 Bootloader TutorialsRT-Thread RTOS Tutorials
Zephyr RTOS Tutorials - STM32Zephyr RTOS Tutorials - ESP32
AUTOSAR TutorialsUDS Protocol Tutorials
Product ReviewsSTM32 MikroC Bootloader Tutorial
VHDL Tutorials
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Table of Contents