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

LCD problem

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



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

LCD problem
PostPosted: Mon Sep 10, 2007 4:44 pm     Reply with quote

i am having a problem with a 4x20 LCD.

here is the test code

Code:
#include <16F628a.H>
#fuses XT, NOWDT, NOPROTECT
#use delay(clock = 4000000)
#include <Flex_LCD420.c>   

//===================================
void main()
{

// The lcd_init() function should always be called once,
// near the start of your program.
lcd_init();

printf(lcd_putc, "\f");
delay_ms(500);

while(1)
  {
   
   output_high(pin_a0);
   delay_ms(100);
   output_low(pin_a0);
   
   
   // Test the clear screen and newline commands.
   // Also test that we can write to all 4 lines.
   printf(lcd_putc, "\fThis is the 1st line");
   printf(lcd_putc, "\nNext is the 2nd line");
   printf(lcd_putc, "\nThis is the 3rd line");
   printf(lcd_putc, "\nFinally the 4th line");
   delay_ms(3000);

   printf(lcd_putc, "\f");
   delay_ms(500);
   
     }   

}


pins on pic16f628a are defined as below in the flex_lcd file

Code:
#define LCD_DB4   PIN_B0
#define LCD_DB5   PIN_B1
#define LCD_DB6   PIN_B2
#define LCD_DB7   PIN_B3

#define LCD_RS    PIN_B4
#define LCD_RW    PIN_B5
#define LCD_E     PIN_B6


i have put the Flex_lcd420.c file in witht the other lib's is that the correct place for it?

i put the led in on pin a0 to see if it was working but it doesnt flash so i presume it is not cycling throught the code in the while(1) loop.

anyone know what is wrong?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 10, 2007 4:52 pm     Reply with quote

Quote:
#fuses XT, NOWDT, NOPROTECT

Add NOLVP to the #fuses statement. It's essential.
umka



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

PostPosted: Tue Sep 11, 2007 12:44 am     Reply with quote

still no luck. i have just wired the lcd terminals to the pic terminals that corrispond in the flex file. anything else i may be doing wrong?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 11, 2007 12:53 am     Reply with quote

Quote:
I have just wired the lcd terminals to the pic terminals

You must also connect power and ground, and the contrast voltage.
Use a trimpot to set the contrast voltage to 0.4 volts. The LCD data
sheet will tell you what pins to use for these.
umka



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

PostPosted: Tue Sep 11, 2007 1:19 am     Reply with quote

sorry i have already done this and still no luck. if i change the trim pot i get the contrast and all line are "active" but no text is being written. it is cycling throught the code though.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 11, 2007 1:22 am     Reply with quote

Post the manufacturer and part number of your LCD.
umka



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

PostPosted: Tue Sep 11, 2007 2:51 am     Reply with quote

this is the data sheet for the lcd. thats all the info i have

http://www.sure-electronics.net/mcu,display/DE-LM005.pdf
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 11, 2007 11:45 am     Reply with quote

This page shows photos of the LCD.
http://www.sure-electronics.com/products/display/de-lm005.html
The data sheet shows that it's a normal 20x4 LCD. The flex driver
should work.

I suggest that you try the CCS driver: LCD420.c
It's in this directory:
Quote:
c:\Program Files\Picc\Drivers

It's setup to use PortB. The pin list is slightly different than the list
in your post. I suggest that you change your board so it fits the CCS
driver, and then try it.
umka



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

PostPosted: Tue Sep 11, 2007 10:55 pm     Reply with quote

still no luck. might it be because it is a 16f628a chip?

when i connect the lcd to power, with all data wires disconnected and adjust the contrast it only makes line 2 and 4 fill with no change to line 1 and 3.

might there be a problem witht he lcd??
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 11, 2007 11:21 pm     Reply with quote

Post your compiler version. It's given at the top of the .LST file.
You can find the .LST file in your project directory. The version
number is a 4-digit number in this format: x.xxx
Post it and I'll check if there is a problem with your version.
umka



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

PostPosted: Wed Sep 12, 2007 12:24 am     Reply with quote

it is Version 3.249
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 12, 2007 1:22 am     Reply with quote

I installed vs. 3.249 and tested your program on a PicDem2-Plus board
with a CrystalFontz 20x4 LCD. I was able to make it work.
I had to do these things:

1. Add NOLVP to the #fuses shown in your program.

2. Remove the LCD connection to pin B2 on the PIC, and move it to
pin B7. Also change the #define statement for the LCD_DB6 pin
so it uses PIN_B7.

3. Unplug the ICD2 cable, to let the PIC program run.


The reason for not using Pin B2 is because on my PicDem2-Plus board,
there is a MAX232A chip which drives that pin. Pin B2 is the Rx pin for
the RS-232 port on the PIC.

The reason for unplugging the ICD2 cable, is because it uses pins B6 and
B7 to communicate with the PIC. The PIC program can't talk to the
LCD while the ICD2 is attached to the board.
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