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

[Help] LCD.c and flex_lcd.c

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



Joined: 05 Nov 2009
Posts: 7
Location: Viet Nam

View user's profile Send private message

[Help] LCD.c and flex_lcd.c
PostPosted: Fri Apr 16, 2010 10:10 am     Reply with quote

Hi everybody!
I'm using PIC16F887 and LCD 16x2.
I've problem: use flex_lcd.c is OK, but use lcd.c of CCS library the LCD display not right (#).
My code here:

Code:
#include <16F887.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)


#include <lcd.c>
//#include "flex_lcd.c"

#define LCD_DATA4    PIN_D0
#define LCD_DATA5    PIN_D1
#define LCD_DATA6    PIN_D2
#define LCD_DATA7    PIN_D3

#define LCD_ENABLE_PIN   PIN_A1
#define LCD_RS_PIN   PIN_A3
#define LCD_RW_PIN   PIN_A2

//==========================
void main()
{
   lcd_init();  // Always call this first.
   
   while(1)
   {
      lcd_gotoxy(1,1);
      printf(lcd_putc,"Hello you");
      lcd_gotoxy(1,2);
      printf(lcd_putc,"PIC16F887");
   }
}

I use internal crystal.
I did not edit #define in LCD.c file and CCS version is 4.105.
Thanks for all!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 16, 2010 11:02 am     Reply with quote

If a file looks for #define statements, you need to put them above
the #include statement for the file. Example:
Code:

#include <16F887.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#define LCD_DATA4    PIN_D0
#define LCD_DATA5    PIN_D1
#define LCD_DATA6    PIN_D2
#define LCD_DATA7    PIN_D3

#define LCD_ENABLE_PIN   PIN_A1
#define LCD_RS_PIN   PIN_A3
#define LCD_RW_PIN   PIN_A2

#include <lcd.c>
 
8051topic



Joined: 05 Nov 2009
Posts: 7
Location: Viet Nam

View user's profile Send private message

PostPosted: Sat Apr 17, 2010 6:07 am     Reply with quote

Thank you very much.
It's worked perfectly.
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