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

HD44780 (4bit mode) Problem

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



Joined: 20 Feb 2011
Posts: 8

View user's profile Send private message

HD44780 (4bit mode) Problem
PostPosted: Mon Sep 19, 2011 6:32 pm     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 19, 2011 7:49 pm     Reply with quote

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);
}
henriquesv



Joined: 20 Feb 2011
Posts: 8

View user's profile Send private message

PostPosted: Tue Sep 20, 2011 3:46 am     Reply with quote

Thanks PCM!
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