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

Error when printing to LCD

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



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

Error when printing to LCD
PostPosted: Fri Jul 15, 2011 3:10 pm     Reply with quote

Hi I am using the "flex_lcd.c" driver for a 2X16 lcd module. I am using a PIC24FV32KA304 with the PCD compiler (V4.122), however I keep getting an error whenever I try to print some characters to the display such as:

lcd_putc('\f');
lcd_gotoxy(1,1);
lcd_putc("Hello World"); -------> this gives me Error 90 "Attempt to create pointer to a constant" when ever I compile

However if I use the following: printf(lcd_putc,"Hello World"); it compiles and works fine!

I have always in the past used lcd_putc("xxxx"); without any problems, I thought that lcd_putc() takes each char at a time from within the string delimiter? I'm I missing something???? Embarassed Embarassed
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Sat Jul 16, 2011 10:07 am     Reply with quote

It appears that I am not imagining this; in the past I took for granted the following feature on the CCS compiler and for some reason it no longer applies, at least with my compiler version using PCD. However, the manual indicates this is a built in function?

From the latest PCD compiler Manual:

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.");

The above returns: Error 90 "Attempt to create pointer to a constant"
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 16, 2011 1:09 pm     Reply with quote

Most of us don't have the PCD compiler, so we can't test it. You could
take your program that fails with PCD, and modify it slightly so it can be
tested with PCH or PCM. See if it fails with those compilers. If so, then
post the program. If the problem is limited to PCD, then email CCS support.
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Mon Jul 18, 2011 4:18 pm     Reply with quote

As usual...Thank you PCM programmer!!

The problem seems to be related to the PCD compiler, this is what I got from the CCS support guys:

Change the function parameter to a "unsigned char" and it will work. We will fix it in the next release.

Thought I save someone some aggravation Twisted Evil Laughing
Ttelmah



Joined: 11 Mar 2010
Posts: 19224

View user's profile Send private message

PostPosted: Tue Jul 19, 2011 2:25 am     Reply with quote

I can see exactly what is happening.
On the older compilers, an 'int', implies an int8. On PCD, an int, implies an int16. Also the default in PCD is signed, where the older compiler defaulted to unsigned.
A couple of versions ago, the 'signed' default, was extended to include int8, and char types.
The 'shortcut' of being able to put a constant string into a function expecting a series of characters works on the older compiler with functions defined as receiving int, int8, or char. On the PCD compiler, you now have to be explicit, and have the functions expecting 'unsigned int8', or 'unsigned char', before the shortcut is activated, since now PCD, treats types as signed, unless explicitly told otherwise....

Best Wsihes
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