View previous topic :: View next topic |
Author |
Message |
neddie Guest
|
CCS lcd.c driver question. |
Posted: Tue Apr 29, 2008 2:39 am |
|
|
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
|
|
Posted: Tue Apr 29, 2008 8:56 am |
|
|
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. |
Posted: Tue Apr 29, 2008 2:27 pm |
|
|
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 |
|
|
|