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 support@ccsinfo.com

CCS lcd.c driver question.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
neddie
Guest







CCS lcd.c driver question.
PostPosted: Tue Apr 29, 2008 2:39 am     Reply with quote

Hi to all.
I am a little confused about how the "lcd_putc" function works.
It is called for instance like this : lcd_putc("hello world");
The function accepts a 'char' an an argument.
Should it not receive a pointer to char?

I am trying to get this code to run on a different compiler (Codewarrior)
and it complains that it is receiving " signed char * " and it's expecting "signed char "

Is the CCS compiler handling this differently than normal?

My "C" is not that great , so I may be missing something here!!
Cheers
Rob

Here is a copy of the lcd_putc function.

Code:

void lcd_putc( char c)
 {
   switch (c) {
     case '\f'   : lcd_send_byte(0,1);
                   delay_ms(2);
                                           break;
     case '\n'   : lcd_gotoxy(1,2);        break;
     case '\b'   : lcd_send_byte(0,0x10);  break;
     default     : lcd_send_byte(1,c);     break;
   }
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Apr 29, 2008 8:56 am     Reply with quote

Yes, the CCS compiler is handling this different. From the manual:
Quote:
A (non-standard) feature has been added to the compiler to help get around the problems created
by the fact that pointers cannot be created to constant strings. A function that has one CHAR
parameter will accept a constant string where it is called. The compiler will generate a loop that will
call the function once for each character in the string.

Example:
void lcd_putc(char c ) {
...
}

lcd_putc ("Hi There.");
neddie
Guest







CCS lcd.c driver question.
PostPosted: Tue Apr 29, 2008 2:27 pm     Reply with quote

Thanks for the help. I was not aware of that limitation.
I have rewritten the function in the new compiler to accept
a pointer to a string , and it works great.
Thanks again.
Cheers
Rob
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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