Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LCD Code explanation needed~

Status
Not open for further replies.

alpha91

Full Member level 3
Joined
Sep 23, 2011
Messages
168
Helped
1
Reputation
2
Reaction score
2
Trophy points
1,298
Activity points
2,625
Hi all, I am learning the custom LCD character which interface withIC 16f628a interface.
My code is as below which i refer online. It works, but i am not understand some part of the code which i highlighted. Can anyone try to explain to me?
// LCD module connections
sbit LCD_RS at RA0_bit; // sbit declares LCD_RS at RA_0 address
sbit LCD_EN at RA1_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISA0_bit;
sbit LCD_EN_Direction at TRISA1_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
#pragma config CP = ON

// End LCD module connections
void CustomChar1(char pos_row, char pos_char);
char message1[] = "I";
char message2[] = "Everyone";
void main() {
CMCON = 0x07;
while (1){
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CURSOR_OFF); // OFF cursor
Lcd_Cmd(0x01); // Clear display
Lcd_Cmd(0x03);
Lcd_out(1,1,message1);
Lcd_out(1,5,message2);
CustomChar1(1,3);

delay_ms (3000);
}
}

const char character[] = {0,27,31,31,14,4,0,0};
void CustomChar1(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);

}

 

Considering that you did not mention exactly which alphanumeric display controller were used, by some guesing:

Code:
Lcd_Cmd(64); // [B]Base address where customized character is going to be stored[/B]
for (i = 0; i<=7; i++) Lcd_Chr_CP(character[i]); // [B]Sequentially stores each of the 8 subsequent rows [/B]
 
Considering that you did not mention exactly which alphanumeric display controller were used, by some guesing:

Code:
Lcd_Cmd(64); // [B]Base address where customized character is going to be stored[/B]
for (i = 0; i<=7; i++) Lcd_Chr_CP(character[i]); // [B]Sequentially stores each of the 8 subsequent rows [/B]

Sorry about that, i am using a 16x2 LCD module.
Lcd_Chr(pos_row, pos_char, 0);

How about this row?
 

Hi,

The bold code generates a custom character. Here it is an icon, a little heart.

Klaus
 
Hi,

The bold code generates a custom character. Here it is an icon, a little heart.

Klaus

Hi, thanks. yes, because i wrote this code.
but i want to understand how the code works row by row because i am using the MikroC generator to do this.
 

Code:
const char character[] = {0,27,31,31,14,4,0,0}; [B]Graphic data[/B]
void CustomChar1(char pos_row, char pos_char) {
 char i;
 Lcd_Cmd(64);           [B]Set CGRAM address to '00'[/B]
 for (i = 0; i<=7; i++) Lcd_Chr_CP(character[i]);   [B]Write custom character graphic data to character pos '00'[/B]
 Lcd_Cmd(_LCD_RETURN_HOME);  [B]Set LCD command[/B]
 Lcd_Chr(pos_row, pos_char, 0);   [B]Write chr code '00' to the correct LCD position[/B]

Description in quote above.

The saved graphic character will be displayed if you write a character code =00.

The first 8 character codes are mapped to the CGRAM, so you may use up to 8 such graphics. They will normally also repeat for the next 8 chr codes. before the characters in the charactr ROM. So instead of using code 00, you get the same character for code 08. This is practical when you write strings in C, since '00' is the end-of-string character.
 
Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top