Discussion in "PIC Microcontroller Discussion" started by    Jaspal_1    Oct 29, 2007.
Mon Oct 29 2007, 03:17 pm
#1
Firstly let me say that the LCD tutorial is awesome and has helped me grasp the basics.
I am using CCS compiler to program PIC18F450.
I am trying to display custom characters but cannot get it quiet right. I really appreciate if someone could highlight my error and tell me the right technique.
My functions are as follows:

void lcd_build() // fuction to create custom pattern
{
lcd_goto(0x40); // save at location 0x40
LCD_RS = 1;
LCD_RW = 0;
lcd_write(0x04); // bell pattern.
lcd_write(0x0e);
lcd_write(0x0e);
lcd_write(0x0e);
lcd_write(0x1f);
lcd_write(0x00);
lcd_write(0x04);
lcd_write(0x00);
delay_ms(20);
LCD_RS = 0;
lcd_clear();
}

void lcd_customdisplay() // displaying the bell pattern

{
LCD_RS = 1;
LCD_RW = 1;
lcd_goto(0x40);
lcd_write(0x00);
lcd_write(0x01);
lcd_write(0x02);
lcd_write(0x03);
lcd_write(0x04);
lcd_write(0x05);
lcd_write(0x06);
lcd_write(0x07);
}
Mon Oct 29 2007, 07:29 pm
#2
ok first i need little info about the functions you are using..

lcd_write = for writing data?
lcd_goto = to send command?

the character stored at location 40 of CGRAM, is called by code '0'
i.e. after building the character once in the program. you can simply display it as..
lcd_write(0);

Please give me little info about the functions you are using above so i can help you in better way..
 Jaspal_1 like this.
Tue Oct 30 2007, 11:44 am
#3
thats right,

lcd_write = for writing data
lcd_goto = to send command

As you pointed out, I am not calling display correctly,
the right function should be

void lcd_customdisplay()
{
LCD_RS = 1;
lcd_write(0);
}


THis works for 1 custom character.
When i tried creating two display characters and calling them one by one, teh second character didnt display correctly. Perhaps i am not calling it correctly.

i have simply modified the functions,
void lcd_build1()
{

lcd_goto(0x40); // pointer to location 0x40.
LCD_RS = 1;
LCD_RW = 0;
lcd_write(0x04); // pattern. This writes bell.
lcd_write(0x0e);
lcd_write(0x0e);
lcd_write(0x0e);
lcd_write(0x1f);
lcd_write(0x00);
lcd_write(0x04);
lcd_write(0x00);
lcd_clear();
}

void lcd_build2()
{

lcd_goto(0x48); // pointer to location 0x48.
LCD_RS = 1;
LCD_RW = 0;
lcd_write(0x00); // pattern. This writes smiley.
lcd_write(0x0a);
lcd_write(0x00);
lcd_write(0x04);
lcd_write(0x04);
lcd_write(0x11);
lcd_write(0x0e);
lcd_write(0x00);
lcd_clear();
}


void lcd_customdisplay1()
{
LCD_RS = 1;
lcd_write(0);
}

void lcd_customdisplay2()
{
LCD_RS = 1;
lcd_write(0x02);
}



all i do in main is ::

void main()
{

TRISD = 0b00000000;
TRISA = 0b00100000;
// TRISA = 0b00000000;
TRISB = 0b00000000;


lcd_init();
lcd_clear();
lcd_build1();
lcd_build2();
lcd_clear();


lcd_goto(0xc0);
lcd_customdisplay1();
lcd_goto(0xc3);
lcd_customdisplay2();
delay_ms(2000);
lcd_clear();
}

It does not disply a smiley at location 0xc3.


CAn anybody point out whats wrong?


Tue Oct 30 2007, 11:47 am
#4
oops,

that is the dumbest mistake anybody can make..

lcd_customdisplay1(); should have

{
LCD_RS = 1;
lcd_write(0x01);

}
Tue Oct 30 2007, 12:47 pm
#5
no custom display1 should have
lcd_write(0x00); not 0x01

you are actually confusing yourself.. and custom display 2 have 0x01

char defined at location 0x40 is called using 0x0
0x48 - 0x01
0x50 - 0x02
0x58 - 0x03
0x60 - 0x04
0x68 - 0x05
0x70 - 0x06
0x78 - 0x07

hope you understand now you can only have 8 custom chars..
for more information take a look at the lcd tutorial..

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

AntoniaRoons
Fri Apr 19 2024, 09:59 pm
carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am