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

Flexible LCD driver
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
Praad



Joined: 15 May 2008
Posts: 5

View user's profile Send private message

PostPosted: Thu May 15, 2008 1:07 pm     Reply with quote

PCM programmer wrote:
In your schematic, you have the R/W pin connected to ground.
With that connection, you must "comment out" the following line
in the Flex LCD driver. Do this by adding comment symbols in
front of the line. Example:
Quote:
// #define USE_LCD_RW 1


Then re-compile and test it.


This morning i did :

Code:

#define USE_LCD_RW   0   



Is this the same thing?

I'll try it as soon as possible (Monday... :s)


thx²
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 15, 2008 1:24 pm     Reply with quote

Absolutely not !

If you define it as 0, it is still defined !

You must comment it out if the R/W line is connected to ground.
Praad



Joined: 15 May 2008
Posts: 5

View user's profile Send private message

PostPosted: Thu May 15, 2008 1:38 pm     Reply with quote

Ok thx for your help PCM Programmer.
I'll try it Monday Very Happy
Praad



Joined: 15 May 2008
Posts: 5

View user's profile Send private message

PostPosted: Sat May 17, 2008 5:56 am     Reply with quote

By using the lib how could i clear a line (the first or the second) ?
I ask that because i would like to print a string which is displayed blinking.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 17, 2008 10:11 am     Reply with quote

Please ask general questions about using an LCD in the main forum.
netmonster



Joined: 08 Aug 2008
Posts: 1

View user's profile Send private message

lcd_Print
PostPosted: Fri Aug 08, 2008 6:33 am     Reply with quote

Hi all,
I really thank u for this amazing driver, I'm using it to dive my LCD 2X16 and it is perfect.

Well I wanted to add some extensions to the driver and I'll post them as soon as i finish...

Good luck all
Very Happy
zafzaf82



Joined: 20 Jun 2006
Posts: 1

View user's profile Send private message

PostPosted: Thu Sep 04, 2008 5:34 pm     Reply with quote

Code:

/* for 4x20 LCD and 2x16 LCD
 * Filename : lcd.c
 * Hardware : Controller  -> all pic series
 */

/**** LCD pinleri ****/
#define LCD_en PIN_D2  //lcdyi yetkilendirmek icin
#define LCD_rs PIN_D3  //konut yada kod yapmak icin
#define LCD_D7 PIN_D7  //lcd veri yolu pin tasarrufu için 4 bit kullandık
#define LCD_D6 PIN_D6
#define LCD_D5 PIN_D5
#define LCD_D4 PIN_D4
/*********************/
//LCD_rw ucu 0'a bagli

#define lcd_line_bir  0x80 // LCD RAM adres 1. satir
#define lcd_line_iki  0xC0 // LCD RAM adres 2. satir
#define lcd_line_uc   0x94 // LCD RAM adres 3. satir
#define lcd_line_dort 0xD4 // LCD RAM adres 4. satir

/***************************************************
 * Prototype(s)                                    *
 ***************************************************/
void LCD_yetkilendirme();                          // LCD yetkilendirme
void LCD_komut(unsigned char komut);               // LCD komut
void LCD_putc(unsigned char ascii);                // LCD tek karakter yazma
void LCD_string_yaz(unsigned char *lcd_string);    // LCD string yazma
void LCD_init();
void LCD_goto_xy(unsigned char x,unsigned char y);

/***************************************************
 * Sources                                         *
 ***************************************************/

//===================================================
void LCD_yetkilendirme()
//===================================================
{
    output_bit( LCD_en , 0); /* Clear bit EN */   //lcd yi bir kere yetki,lendirmek için
    delay_ms(2);
    output_bit( LCD_en , 1); /* Set bit EN */
}

//===================================================
void LCD_komut(unsigned char komut)   //lcdye komut gönder
//===================================================
{
   unsigned char nibble;
   output_bit( LCD_rs , 0); /* Clear bit RS */
   nibble = (komut>>4) & 0x0F;  //ilk 4 bitini gönderdik
   output_bit(LCD_D4 , (nibble & 0x01) );       //pinlere tek tek gönderdik. buton tek seferde göndermediği için
   output_bit(LCD_D5 , (nibble>>1 & 0x01) );
   output_bit(LCD_D6 , (nibble>>2 & 0x01) );
   output_bit(LCD_D7 , (nibble>>3 & 0x01) );
   LCD_yetkilendirme();
   nibble = komut & 0x0F;
   output_bit(LCD_D4 , (nibble & 0x01) );       
   output_bit(LCD_D5 , (nibble>>1 & 0x01) );
   output_bit(LCD_D6 , (nibble>>2 & 0x01) );
   output_bit(LCD_D7 , (nibble>>3 & 0x01) );
   LCD_yetkilendirme();
   delay_ms(2);
   }
//===================================================
void LCD_putc(unsigned char ascii)   //karakter gönderir. tek karakter
//===================================================
{   
   unsigned char nibble;
   output_bit( LCD_rs , 1); /* Set bit RS *///veri gönderdiğin için 1 oldu.
   nibble = (ascii>>4) & 0x0F;//0x0f ile maskeliyor.
   output_bit(LCD_D4 , (nibble & 0x01) );       //pinlere tek tek gönderdik. buton tek seferde göndermediği için
   output_bit(LCD_D5 , (nibble>>1 & 0x01) );
   output_bit(LCD_D6 , (nibble>>2 & 0x01) );
   output_bit(LCD_D7 , (nibble>>3 & 0x01) );
   LCD_yetkilendirme();
   nibble = ascii & 0x0F;
   output_bit(LCD_D4 , (nibble & 0x01) );   
   output_bit(LCD_D5 , (nibble>>1 & 0x01) );
   output_bit(LCD_D6 , (nibble>>2 & 0x01) );
   output_bit(LCD_D7 , (nibble>>3 & 0x01) );
   LCD_yetkilendirme();
   delay_ms(2);
}

//===================================================
void LCD_string_yaz(unsigned char *lcd_string)
//===================================================
{
   while (*lcd_string)
   {
      LCD_putc(*lcd_string++);
   }
}

void LCD_init()
{
    output_bit( LCD_en , 1); /* Set bit EN */
    output_bit( LCD_rs , 0); /* CLr bit RS */ 
    LCD_komut(0x33);
    LCD_komut(0x32);
    LCD_komut(0x28);
    LCD_komut(0x0C);
    LCD_komut(0x06);
    LCD_komut(0x01); /* Clear */
    delay_ms(100);
}

//===================================================
void LCD_goto_xy(unsigned char x, unsigned char y)   //lcdye istediğimiz yere veri yazmamızı sağlar. satir ve sütün olarak
//x ,y=sutun,satir
//===================================================
{
int adres;  //ramdeki adresi tutar

   switch( y )
   {
   case 1:
   adres = lcd_line_bir;
   break;
   case 2:
   adres = lcd_line_iki;
   break;
   case 3:
   adres = lcd_line_uc;
   break;
   case 4:
   adres = lcd_line_dort;
   break;
   }

   adres += x-1;     
   LCD_komut(adres); //lcdye veri gönderiyor
}



Code:

#include <18F452.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=40000000,,RESTART_WDT)
#use rs232(baud=57600, xmit=PIN_C6, rcv=PIN_C7)
#ORG 0x7000,0x7FFF {} // Added for bootloader
#include <stdio.h>
#include "LCD_zafer.c"

void main()
{
   setup_adc_ports( ADC_OFF  );
   SETUP_ADC(ADC_OFF);
   DISABLE_INTERRUPTS(GLOBAL);
   SETUP_CCP1(CCP_OFF);
   SETUP_CCP2(CCP_OFF);
   SET_TIMER0(RTCC_OFF);
   SET_TIMER1(T1_DISABLED);
   SET_TIMER3(T3_DISABLED);
   
   output_d(0x00);
   
   LCD_init();
   LCD_goto_xy(1,1);
   printf(LCD_putc,"    ZAFER ONUR      ");
   LCD_goto_xy(1,2);
   printf(LCD_putc,"  LCD DENEME V1.0   ");
   LCD_goto_xy(1,3);
   printf(LCD_putc,"********************");
   LCD_goto_xy(1,4);
   printf(LCD_putc,"********************");
   
   
   
   while(true);
}
peaps



Joined: 15 Sep 2008
Posts: 11
Location: Hemel Hempstead, Hertfordshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Mon Sep 15, 2008 3:26 pm     Reply with quote

Hi,

I would like to mention a potential problem with this library, or maybe I'm doing something wrong..

When I use the \n newline I get a garbage character output to the LCD. I have tried using a 16x2 device and also an 8x2 which did work, but also outputted the same weird character. I have remmed out the #define USE_LCD_RW line and set the pin constants, but apart from that the code is vanilla as taken from the first post.

Does anyone else get this symptom? Using latest compiler on a 16F819.

Thanks,

Andy Peaple.

Code:
#include <16f819.h>
#fuses INTRC_IO, NOWDT, NOPUT, NOMCLR, NOBROWNOUT, NOCPD
#use delay(clock=8000000)
#include <flex_lcd.c>

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

      setup_oscillator(OSC_8MHZ);
      setup_ccp1(CCP_OFF);
      setup_adc(ADC_OFF);
      setup_adc_ports(NO_ANALOGS);

delay_ms(2000);
lcd_init();  // Always call this first.

lcd_putc("\fHello World\n");
lcd_putc("Line Number 2");

while(1);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 15, 2008 3:33 pm     Reply with quote

1. Post the manufacturer and part number of the 16x2 LCD.

2. Post your compiler version.

3. Post the list of #define statements for the pin connections
between the PIC and the 16x2 LCD.

4. Post the list of physical connections (wires or tracks) between
the LCD and the PIC.

5. Have you connected the R/W pin on the LCD to ground ?
If not, what is it connected to ?
peaps



Joined: 15 Sep 2008
Posts: 11
Location: Hemel Hempstead, Hertfordshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Mon Sep 15, 2008 3:58 pm     Reply with quote

1. Display is made by: Orient Display Co. Ltd., part no. OD-DM1602F.
2. Compiler version: 4.013

3. LCD pin defines:

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

#define LCD_E PIN_A2
#define LCD_RS PIN_A3
#define LCD_RW PIN_A4

4. Pin mappings:

PIN_A2 -=> Enable
PIN_A3 -=> Register Select
PIN_B0 -=> Data_7
PIN_B1 -=> Data_6
PIN_B2 -=> Data_5
PIN_B3 -=> Data_4

PIN_A4 is not connected to anything.

5. The R/W terminal on the LCD module is tied directly to ground.

Thanks
Andy P.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 15, 2008 4:35 pm     Reply with quote

I don't have vs. 4.013. I have 4.014 and compiled it for that, and
compared the .LST file to vs. 4.079. They're effectively the same.
You don't have the NOLVP fuse but the compiler sets that for you
so that's not the problem. (However, check the end of your .LST
file to confirm this, since you are using a slightly earlier version).

It's possible that there's a problem with the lack of using the R/W pin.
There are several ways to test this.

1. You could remove the GND on the LCD's R/W pin and connect it
to pin A4 on the PIC. Uncomment the USE_RW_PIN line in the
flex driver file. See if it now works when the R/W pin is used.

Or,

2. It's possible that the problem is caused by sensitivity in your LCDs
to the size of the delays in the flex driver. You could increase the
delay in the send_byte() routine from 60 us, to say, 100 us or more.

Also,

You could temporarily reduce the speed of the internal oscillator. Set
your use delay statement to 1 MHz. Change the setup_oscillator()
statement to 1 MHz. You actually don't need this statement. When the
compiler sees the fuse #use delay() statement, it puts in code which
does the same thing as the setup_oscillator() statement. But anyway,
see if the lower oscillator frequency makes it start working. If so, this
is a clue that the delays in the flex driver must be increased for your LCD.
peaps



Joined: 15 Sep 2008
Posts: 11
Location: Hemel Hempstead, Hertfordshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Tue Sep 16, 2008 4:02 pm     Reply with quote

Hi, thanks for the reply.

I have tried connecting the R/W pin to the LCD module, increasing the delay from 60us to 500us and reducing the clock speed of the PIC to 1Mhz, but unfortunately I still get the weird character after a new line.

I have also tried it on a different LCD, a 16x1. I get a different type of character on this module.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 16, 2008 4:13 pm     Reply with quote

Try the CCS LCD driver.
Quote:
c:\program files\picc\drivers\lcd.c


Or try Mark's more flexible version of it:
http://www.ccsinfo.com/forum/viewtopic.php?t=20182
peaps



Joined: 15 Sep 2008
Posts: 11
Location: Hemel Hempstead, Hertfordshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Mon Sep 29, 2008 1:25 pm     Reply with quote

Just tried the CCS driver lcd.c, but still getting weird char at a \n.

Similar code still...
Code:
#include <16f819.h>
#use delay(clock=1000000)
#include <lcd.c>
#fuses INTRC_IO, NOWDT, NOPUT, NOMCLR, NOBROWNOUT, NOCPD
#bit LED = 5.1


void main(void) {

//   set_tris_a(0b00000000);
   setup_oscillator(OSC_1MHZ);
   setup_ccp1(CCP_OFF);
   setup_adc(ADC_OFF);
   setup_adc_ports(NO_ANALOGS);

   LED = 1;
   delay_ms(1000);
   LED = 0;


   lcd_init();

   while(1==1) {
      delay_ms(500);
      LED = 1;
      lcd_putc("\f12345678");
      delay_ms(500);


      lcd_putc("\f********\n--------");
      delay_ms(250);
   }

}


I'll try that other library you mentioned next..
Andy
peaps



Joined: 15 Sep 2008
Posts: 11
Location: Hemel Hempstead, Hertfordshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Sat Oct 04, 2008 10:40 am     Reply with quote

I have found out what the problem is, and frankly, I am surprised that no one else has come across this before. This problem also exists with the CCS lcd.c driver that ships with the compiler.

The strange character is not due to '\n' but rather NULL CHARS at the end of strings.

When calling lcd_putc("Hello World");

a '\0' also gets sent at the end of the string which the LCD just outputs as garbage.

To get around this problem I have made a very small ammendment to the lcd_putc() function:

Quote:
void lcd_putc( char c) {
switch (c) {
case '\f' : lcd_send_byte(0,1);
delay_ms(2);
break;
case '\n' : lcd_gotoxy(1,2); break;
case '\b' : lcd_send_byte(0,0x10); break;
// do nothing in case of Null char
case '\0' : break;

default : lcd_send_byte(1,c); break;
}
}


Note the additional switch statement that handles null chars.

Andy Peaple
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Page 5 of 7

 
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