![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
henriquesv
Joined: 20 Feb 2011 Posts: 8
|
HD44780 (4bit mode) Problem |
Posted: Mon Sep 19, 2011 6:32 pm |
|
|
Hello everyone, I've been into some problem with ccs compiler...
Can't it parse a const char pointer on PIC16? Perhaps is doesn't have direct access to rom? Am I being reasonable?
Here's a piece of code it is complaining about (I can post the full code if it is needed):
The first error line points to the
Code: |
extern void lcd_puts(const char * s);
...
...
void lcd_puts(const char * s)
{
output_bit(LCD_RS,1);
while(*s)
lcd_write(*s++);
}
|
And the first error lines are:
*** Error 28 "C:\swf\Firmware\lcd.h" Line 30(156,160): Expecting an identifier
*** Error 48 "C:\swf\Firmware\lcd.h" Line 30(158,159): Expecting a (
*** Error 43 "C:\swf\Firmware\lcd.h" Line 30(160,161): Expecting a declaration
Thank you.
Best Regards |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 19, 2011 7:49 pm |
|
|
Your problem doesn't have anything to do with the HD44780 lcd.
It's about the interpretation of the 'const' keyword by CCS.
In the early days of CCS, they decided that 'const' would mean that
data is stored in ROM, instead of RAM. They continued that definition
as the default even today. But if you want the ANSI-style 'const', you
can have it. You can do it by adding the #device statement as shown
below. This is in the CCS manual in the #device section.
Code: |
#include <18F452.h>
#device CONST=READ_ONLY
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
void my_puts(const char *s)
{
while(*s)
{
putc(*s++);
}
}
const char msg[] = "Hello World";
//=======================================
void main()
{
my_puts(msg);
while(1);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
henriquesv
Joined: 20 Feb 2011 Posts: 8
|
|
Posted: Tue Sep 20, 2011 3:46 am |
|
|
Thanks PCM! |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|