Contents
- 1 DDRAM, CGROM and CGRAM
- 1.1 CGROM – Character Generator ROM
- 1.2 DDRAM – Display Data RAM
- 1.3 CGRAM – Character Generator RAM
- 2 Character Generation using MikroC
- 2.1 MikroElektronika LCD Custom Char Generator Tool
- 2.2 MikroC Modified Code
- 3 Circuit Diagram
- 4 Output
These character based LCDs are commonly made using HD44780 compatible controllers. It allows us to define 8 custom characters in addition to the standard pre-programmed characters. In this tutorial we will learn to define our own custom characters using MikroC compiler.
DDRAM, CGROM and CGRAM
CGROM – Character Generator ROM
This is the memory which holds 5×8 or 5×10 dot patterns of predefined characters in the LCD. It can generate 208 5×8 dot character patterns and 32 5×10 dot character patterns.
DDRAM – Display Data RAM
This is the memory which holds the character data which is currently displayed on the LCD screen. Its capacity is 80×8 bits, ie 80 characters.
CGRAM – Character Generator RAM
This memory works similar to CGROM but as this is a RAM we can modify its data any time. So we can store our custom character patterns in this memory through program. We can store up to eight 5×8 character dot patterns or four 5×10 character dot patterns in this memory.
Character Generation using MikroC
You can easily create your own custom characters using MikroElectronika LCD Custom Character Generator Tool.
- Go to Tools >> LCD Custom Character
MikroElektronika LCD Custom Char Generator Tool
![]() |
| MikroElektronika LCD Custom Char Generator |
- Set the font size of your LCD
- Set CGRAM Address
- Design your custom character
- Then click on the Generate Code button
This will give you a function to store and display the custom character in the LCD. By changing the CGRAM address you can store up to eight 5×8 custom characters in the LCD memory. You can see a modified MikroC code below, which will store and display 8 custom characters in the LCD.
MikroC Modified Code
// LCD module connections
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
const char character0[] = {0,0,10,31,31,14,4,0};
const char character1[] = {14,27,17,17,17,17,31,0};
const char character2[] = {14,27,17,17,17,31,31,0};
const char character3[] = {14,27,17,17,31,31,31,0};
const char character4[] = {14,27,17,31,31,31,31,0};
const char character5[] = {14,31,31,31,31,31,31,0};
const char character6[] = {0,4,2,31,2,4,0,0};
const char character7[] = {0,0,14,17,17,10,27,0};
void CustomChar0() {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character0[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
}
void CustomChar1() {
char i;
Lcd_Cmd(72);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character1[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
}
void CustomChar2() {
char i;
Lcd_Cmd(80);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character2[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
}
void CustomChar3() {
char i;
Lcd_Cmd(88);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character3[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
}
void CustomChar4() {
char i;
Lcd_Cmd(96);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character4[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
}
void CustomChar5() {
char i;
Lcd_Cmd(104);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character5[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
}
void CustomChar6() {
char i;
Lcd_Cmd(112);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character6[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
}
void CustomChar7() {
char i;
Lcd_Cmd(120);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character7[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
}
void main() {
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
//Send Custom Charactors to CGRAM
CustomChar0();
CustomChar1();
CustomChar2();
CustomChar3();
CustomChar4();
CustomChar5();
CustomChar6();
CustomChar7();
//End
//Display Custom Characters
Lcd_Chr(1,1,0);
Delay_ms(1000);
Lcd_Chr(1,2,1);
Delay_ms(1000);
Lcd_Chr(1,3,2);
Delay_ms(1000);
Lcd_Chr(1,4,3);
Delay_ms(1000);
Lcd_Chr(1,5,4);
Delay_ms(1000);
Lcd_Chr(1,6,5);
Delay_ms(1000);
Lcd_Chr(1,7,6);
Delay_ms(1000);
Lcd_Chr(1,8,7);
Delay_ms(1000);
}
Circuit Diagram
![]() |
| Interfacing LCD with PIC Microcontroller – Circuit Diagram |



Hey, in what version of MikroC is the custom char generator available? I have MickroC version 6 and GLCD is the only available tool. Looking forward for an answer. Thanks.
ReplyDeleteIt is available in v6, MikroC Pro v6
ReplyDelete