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

Device required before this line in flex lcd driver

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



Joined: 11 Aug 2015
Posts: 1

View user's profile Send private message

Device required before this line in flex lcd driver
PostPosted: Tue Aug 11, 2015 12:30 pm     Reply with quote

Hello
http://www.ccsinfo.com/forum/viewtopic.php?t=24661
I have copied your code for 2x16 LCD in a new .c file, and I have saved it in Drivers folder in PICC folder.

I included flex_LCD.c in my program and clicked compile.
An Error occurs tells me this:
***Error 128"flex_LCD.c"Line 27(1,43): A #DEVICE required before this line

The line 27 is this one:
Code:
int8 const LCD_INIT_STRING[4] =
{
 0x20 | (lcd_type << 2),          // Func set: 4-bit, 2 lines, 5x8 dots
 0xc,                                      // Display on
 1,                                         // Clear display
 6                                          // Increment cursor
 };

Even it is not logical to add #DEVICE, I tried it and it gets worst
Please Help
I need this file because I can't choose specific pins using LCD.c.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Aug 11, 2015 5:01 pm     Reply with quote

show your compiler version and ALL your code from the top
not just the snip .

i'm betting the compiler is right however.
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Wed Aug 12, 2015 12:35 am     Reply with quote

Are you using MPLAB?.

This happens if you put files like this into the 'source files' tab. Only the primary C file must be in this. All the other files need to be in the 'other files' tab. If the file is in the source files tab, MPLAB will try to compile this _separately_, which won't work, since it does not contain processor definitions.

Other thing is the general rule about CCS.
Lay your files out in the main project as:

1) Processor defintion/include
2) Extra device statements (ADC etc.).
3) Fuses
4) Clock
5) Pin select (if applicable to your chip)
6) Peripheral setup (RS232 I2C etc.) - use device names not pins if using select.

7) Then include system include files (stdlib etc.)
8) Then your include files - including things like lcd.

9) Then the rest of the code.

These sections can themselves be in separate include files, but the order you meet them as you read down the files in sequence should be like this.

If this is not basically followed all sorts of problems will arise. If (for instance) you include system files using delays, they won't operate correctly till after the clock settings. Clock setting won't necessarily work right till after the fuses. I/O calls won't work correctly till after the peripheral setup, etc., etc..

Including the lcd.c file too early could also give this error.
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