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 Query

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



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

LCD Query
PostPosted: Fri Feb 03, 2006 4:53 am     Reply with quote

Currently I am trying to display some character using my PIC18F... I will be displaying just 3 charcters.. (example character = "98%")

and also planning to use LCD420.C or LCD.C examples....

May I know the model(serial) of LCD panel that you guys recommend me to use....




thx

sonic
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Fri Feb 03, 2006 8:16 am     Reply with quote

I think I can use HD44780 based LCD....

Quote:
http://www.electronic-engineering.ch/microchip/datasheets/lcd/the_lcd_data_sheet.pdf
Razz
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Mon Feb 06, 2006 12:57 pm     Reply with quote

But i bought use S6A0069 as controller....

so can I use LCD.c as the driver????

or where can I get t driver to use in my PIC18F2525??


thx
sonic
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 06, 2006 1:06 pm     Reply with quote

This thread that you posted on explains exactly what needs to be done.
Change the delay_ms(15); to be delay_ms(30);
http://www.ccsinfo.com/forum/viewtopic.php?t=25172

Just do it.
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Mon Feb 06, 2006 1:38 pm     Reply with quote

ok..thx for the support...I will test it out as soon as I get school in few hours time...

By the way, I am using PIC18F2525 with a 2x16 matric LCD based on S6A0069...I use PIC19F2525 PORT B instead of PORT D...

so my changes are...Please read the changes and comment pls...

Code:

struct lcd_pin_map {                 // This structure is overlayed
           BOOLEAN enable;           // on to an I/O port to gain
           BOOLEAN rs;               // access to the LCD pins.
           BOOLEAN rw;               // The bits are allocated from
           BOOLEAN unused;           // low order up.  ENABLE will
           int     data : 4;         // be pin B0.
        } lcd;


#if defined(__PCH__)
#if defined use_portb_lcd
   #byte lcd = 0xF81                   // This puts the entire structure
#else
   #byte lcd = 0xF83                   // This puts the entire structure
#endif
#else

//I comment out as below as I am using PORT B...
//#if defined use_portb_lcd

   #byte lcd = 6                  // on to port B (at address 6)

//#else
   //#byte lcd = 8                 // on to port D (at address 8)
//#endif


#endif

//I comment out as below as I am using PORT B...
//#if defined use_portb_lcd

   #define set_tris_lcd(x) set_tris_b(x)

//#else
   //#define set_tris_lcd(x) set_tris_d(x)
//#endif


#define lcd_type 2           // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40    // LCD RAM address for the second line





Hopefully, I will get it done successfully and will post the driver in code lib forum for other brothers to use...

thx

sonic
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 06, 2006 1:47 pm     Reply with quote

You're doing it completely wrong. Don't make any of the changes
that you have made.

All you have to do is add one #define statement before the
#include statement for the lcd driver. Example:

Quote:

#define use_portb_lcd TRUE // This line tells the driver to use Port B.
#include <lcd.c>

void main()
{
lcd_init();

// etc.

while(1);
}
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Mon Feb 06, 2006 2:01 pm     Reply with quote

PCM programmer wrote:
You're doing it completely wrong. Don't make any of the changes
that you have made.

All you have to do is add one #define statement before the
#include statement for the lcd driver. Example:

Quote:

#define use_portb_lcd TRUE // This line tells the driver to use Port B.
#include <lcd.c>

void main()
{
lcd_init();

// etc.

while(1);
}




thx for your in-time correction....

If not...I will be in deep sh*t,,,,when I at skool...


I also made a mod as i am using S6A0069 chip based LCD

correct me if I do it wrongly again,,,

Code:

//Modified code to fit S6A0069 chip based LCD
void lcd_init() {
    set_tris_lcd(LCD_WRITE);
    lcd.rs = 0;
    lcd.rw = 0;
    lcd.enable = 0;
    delay_ms(30);
   lcd_send_nibble(0x02);
   delay_us(1);
    lcd_send_nibble(0x02);
    delay_us(1);
    lcd_send_nibble(0x0C);
    delay_us(45);
    lcd_send_nibble(0x00);
    delay_us(1);
    lcd_send_nibble(0x0F);
    delay_us(45);
    lcd_send_nibble(0x00);
    delay_us(1);
    lcd_send_nibble(0x01);
    delay_ms(2);
    lcd_send_nibble(0x00);
    delay_us(1);
    lcd_send_nibble(0x06);
    delay_ms(2);

}

//Orignal LCD format
/*
void lcd_init() {
    BYTE i;
    set_tris_lcd(LCD_WRITE);
    lcd.rs = 0;
    lcd.rw = 0;
    lcd.enable = 0;
    delay_ms(15);
    for(i=1;i<=3;++i) {
       lcd_send_nibble(3);
       delay_ms(5);
    }
    lcd_send_nibble(2);
    for(i=0;i<=3;++i)
       lcd_send_byte(0,LCD_INIT_STRING[i]);
}

*/
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Wed Feb 08, 2006 10:26 pm     Reply with quote

jus 1 more query,,,,


as I am using PORT B0-7 for LCD....

at the same time I'm using PORTB 6-7 as PGD and PGC for my ICD programming...


can I tied them together???


sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Thu Feb 09, 2006 6:44 am     Reply with quote

Quote:

at the same time I'm using PORTB 6-7 as PGD and PGC for my ICD programming...


can I tied them together???




after testing out...
i can't tied them together...

so I connect to PGD/PGC when in programming mode to Port B 6 and 7
and connect in PIN 13 and 14 of the LCD when in running mode...
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

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

PostPosted: Thu Feb 09, 2006 8:26 am     Reply with quote

sonicdeejay wrote:
jus 1 more query,,,,


as I am using PORT B0-7 for LCD....

at the same time I'm using PORTB 6-7 as PGD and PGC for my ICD programming...


can I tied them together???


Why whould you want to tie PGD and PGC together? Parsing your "sentance" (and I use that word very loosely here) results in asking to tie PGD and PGC together.

But I think what you are asking is:
Can I use PORTB6 and PORTB7 as both ICSP programming pins and data pins for my LCD?

The answer to that question is yes. Use a series resistor from the PIC to your LCD pins. Start with 4.7kOhm. Then when you connect your programming header, connect it on the PIC side of the resistor. You may need to adjust the resistor value upward.

I have not done this with a LVP system but I have done this with PIC16Fs several times.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Fri Feb 10, 2006 8:52 pm     Reply with quote

I have connected according to the picture below...



To program the chip ..i have to disconnect PIN 14 and 13 of LCD, only then I can program the chip. I have tried 4.7K~6K..no use...


Shocked
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Sun Feb 12, 2006 4:46 am     Reply with quote

PCM and gurus...

help...


sonic
gs



Joined: 22 Aug 2005
Posts: 30
Location: Ioannina - Greece

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

PostPosted: Sun Feb 12, 2006 5:16 pm     Reply with quote

I have tried it this way (with the resistors) but it worked only for some LCD modules. Since then I connect my lcd to PortC
_________________
www.hlektronika.gr
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 12, 2006 6:19 pm     Reply with quote

The problem is that the circuit is not as simple as your drawing shows.

The LCD controller chip has pull-ups on the data lines.
Download the HD44780 data sheet here:
http://www.melabs.com/downloads/hd44780u.pdf
Look on page 51 near the bottom, at the section on "Pull-up MOS current".
The current can be from 50 to 250 ua. With a 5v Vdd, this translates
to a pull-up resistance from 20K to 100K ohms.
A schematic drawing of these pull-ups is shown on page 54 of the
data sheet. They are drawn as a FET, not as a resistor symbol.

Then download the Microchip ICD2 poster:
http://ww1.microchip.com/downloads/en/devicedoc/51265e.pdf
Then zoom in on the middle right side. Notice that the ICD2 has
got 4.7K pull-down resistors on the PGC and PGD pins.

So in fact, the circuit is a voltage divider with 3 resistors in it.

If you can't program the PIC, then it's very likely because the
proper voltage levels are not being maintained, due to the presence
of the voltage divider.
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