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

LCD Interfacing Problem with PIC16F877A

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



Joined: 05 Mar 2012
Posts: 18
Location: India

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

LCD Interfacing Problem with PIC16F877A
PostPosted: Mon Mar 05, 2012 9:13 pm     Reply with quote

Hello everyone i am new to CCS Compiler.
I write a simple code to to display some text on LCD.
But it not works.

Here is my CODE

Code:
#include<16f877a.h>

#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP

#include <lcd.c>

/*#define LCD_ENABLE_PIN  PIN_C0                                    ////
#define LCD_RS_PIN      PIN_C1                                    ////
#define LCD_RW_PIN      PIN_C2                                    ////
#define LCD_DATA4       PIN_D4                                    ////
#define LCD_DATA5       PIN_D5                                    ////
#define LCD_DATA6       PIN_D6                                    ////
#define LCD_DATA7       PIN_D7*/

void main()
{
   set_tris_d(0x00);
   set_tris_c(0x00);
   lcd_init();
    Delay_ms(100);
   while(1)
   {
      lcd_gotoxy(1,1);
      Delay_ms(1000);
      lcd_putc("\fReady...\n");
   }
}


after asking several forums on internet,
someone has given me a file flex_lcd.c

i write the code for that as follow:
Code:

#include<16f877a.h>

#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP

#include "flex_lcd.c"

void main()
{
   set_tris_d(0x00);
   set_tris_c(0x00);
   lcd_init();
    Delay_ms(100);
   while(1)
   {
      lcd_gotoxy(1,1);
      Delay_ms(1000);
      lcd_putc("\fReady...\n");
   }
}


and changed the pin configuration for that, and my lcd program starts working,
so i want to know why the file provided with ccs pic c i.e lcd.c is not working for me...
_________________
Arun Sharma
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 05, 2012 10:21 pm     Reply with quote

You need to place the pin assignment statements above the #include line
for lcd.c. Also, the #define statements must not be commented out.
Example:
Code:

#define LCD_ENABLE_PIN  PIN_C0                                   
#define LCD_RS_PIN      PIN_C1                                     
#define LCD_RW_PIN      PIN_C2                                   
#define LCD_DATA4       PIN_D4                                     
#define LCD_DATA5       PIN_D5                                     
#define LCD_DATA6       PIN_D6                                     
#define LCD_DATA7       PIN_D7

#include <lcd.c>  // This line must go here
 
07arunsharma



Joined: 05 Mar 2012
Posts: 18
Location: India

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

PostPosted: Tue Mar 06, 2012 9:34 am     Reply with quote

Thank You very Much,

It works, i was halted at this problem from last 2 month.
today i got solution..
:-)

what is the meaning of "%f"


Thanks alot..
:-)
_________________
Arun Sharma
07arunsharma



Joined: 05 Mar 2012
Posts: 18
Location: India

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

PostPosted: Tue Mar 06, 2012 10:37 am     Reply with quote

%f is used to clear the LCD Screen,

what if i want to go to a particular line,
i use statement lcd_gotoxy(1,1);
it means 1st row and 1st columns

while
lcd_gotoxy(2,1);
second row first column not working

Can you tell me why it is so.


Code:

#include<16f877a.h>

#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP

#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,parity=N,bits=8,ERRORS)

#define LCD_ENABLE_PIN PIN_C0
#define LCD_RS_PIN PIN_C1
#define LCD_RW_PIN PIN_C2
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7

#include <lcd.c>

void main()
{
   set_tris_d(0x00);
   set_tris_c(0x00);
   lcd_init();
    Delay_ms(100);
   while(1)
   {
      lcd_gotoxy(2,1);
      Delay_ms(1000);
      lcd_putc("\fArun Sharma");   // /f clears the display
      Delay_ms(1000);
      printf("Serial Communication\n\r");
      Delay_ms(1000);
   }
}


This is not working means Arun Sharma is not displaying on Second line..
_________________
Arun Sharma
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Mar 06, 2012 11:52 am     Reply with quote

...
lcd_gotoxy(2,1);
second row first column not working
..
Have a read of the LCD driver comments at the beginning...

(1,2) not (2,1)
07arunsharma



Joined: 05 Mar 2012
Posts: 18
Location: India

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

PostPosted: Tue Mar 06, 2012 12:30 pm     Reply with quote

I have tried all combination..
and it is not written in driver file,

Quote:
///////////////////////////////////////////////////////////////////////////////
//// LCD.C ////
//// Driver for common LCD modules ////
//// ////
//// lcd_init() Must be called before any other function. ////
//// ////
//// lcd_putc(c) Will display c on the next position of the LCD. ////
//// The following have special meaning: ////
//// \f Clear display ////
//// \n Go to start of second line ////
//// \b Move back one position ////
//// ////
//// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) ////
//// ////
//// lcd_getc(x,y) Returns character at position x,y on LCD


This is written,,
Anyways thanks for ur reply,
but still it doesn't works..


Code:
#include<16f877a.h>

#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP

#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,parity=N,bits=8,ERRORS)

#define LCD_ENABLE_PIN PIN_C0
#define LCD_RS_PIN PIN_C1
#define LCD_RW_PIN PIN_C2
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7

#include <lcd.c>

void main()
{
   set_tris_d(0x00);
   set_tris_c(0x00);
   lcd_init();
    Delay_ms(100);
   while(1)
   {
      lcd_gotoxy(1,2);
      Delay_ms(1000);
      lcd_putc("\fArun Sharma");   // /f clears the display
      Delay_ms(1000);
      printf("Serial Communication\n\r");
      Delay_ms(1000);
   }
}


Not working,
Any suggestion pls
_________________
Arun Sharma
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Tue Mar 06, 2012 12:33 pm     Reply with quote

Been a while since I looked at the LCD specs (and they all vary), but I thought there had to be a delay after a "\f" (form-feed / clear display) before you sent it more text ?

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 06, 2012 2:33 pm     Reply with quote

Quote:
I thought there had to be a delay after a "\f" (form-feed / clear display)
before you sent it more text

It's all handled by the lcd driver. Check the source code in the CCS
Code Library forum.
jeremiah



Joined: 20 Jul 2010
Posts: 1346

View user's profile Send private message

PostPosted: Tue Mar 06, 2012 5:28 pm     Reply with quote

I've not dealt with LCD's much, but does the clear screen in lcd_putc("\fArun Sharma") also reset the position? If so, the lcd_gotoxy(1,2) would be meaningless.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 06, 2012 5:47 pm     Reply with quote

Yes, it clears the display and puts the cursor in home position (1, 1).
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