CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with LCM-SO1602DTR/M LCD on Picdem 2 Plus Demo Board
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 05, 2007 3:59 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 05, 2007 4:25 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 05, 2007 4:38 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 05, 2007 4:51 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group