View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Aug 05, 2007 3:59 pm |
|
|
In C, a 'char' variable can only hold one character. You need to declare
an array in order to hold a string. Then to display this string, you need
to use the printf function, and pass it the array as a parameter, and
also redirect the output of printf to the 'lcd_putc' function.
Look at the lines in bold below. They do what I've explained above:
Quote: | void main()
{
char x[] = {"Hello"};
output_high(LCD_POWER); // Turn on power to LCD
delay_ms(100);
output_low(LCD_RW); // Set R/W pin on LCD to a low level
lcd_init(); // Initialize the LCD
printf(lcd_putc, x);
while(1);
} |
The DV164006 part number is for a kit consisting of the ICD2 and the
PicDem2-Plus board. I don't need another ICD2. There's also no
guarantee the Microchip will ship the new Rohs board to me. Anyway,
you got it working, so I don't have to do it. |
|
 |
Dominik
Joined: 04 Aug 2007 Posts: 18
|
|
Posted: Sun Aug 05, 2007 4:25 pm |
|
|
It"s working very good now, thank you very much again !
May I ask you something else, how I have to do if I want to display an "int" value ?
I tried this but it doesn't working :
Code: |
void main()
{
int x=0;
output_high(LCD_POWER); // Turn on power to LCD
delay_ms(100);
output_low(LCD_RW); // Set R/W pin on LCD to a low level
lcd_init(); // Initialize the LCD
printf(lcd_putc, x);
while(1);
}
|
|
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Aug 05, 2007 4:38 pm |
|
|
You need to read about the printf() function. Look in the printf section
of the CCS manual. It lists all the format specifiers that can be used
to display different kinds of variables. You can download it here:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
To display an unsigned 8-bit integer, use the %u specifier, as shown:
Code: | printf(lcd_putc, "%u", x); |
|
|
 |
Dominik
Joined: 04 Aug 2007 Posts: 18
|
|
Posted: Sun Aug 05, 2007 4:51 pm |
|
|
It's perfect !
Thank you for everything Mr PCM Programmer !
I'm downloading the manual now and then I think that I'll be able to program without bothering you all the time.
I will let you know about my final project.
Best regards,
Dominik |
|
 |
|