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&pic18F452 setup

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



Joined: 10 Jun 2005
Posts: 4
Location: Italy

View user's profile Send private message

LCD&pic18F452 setup
PostPosted: Tue Jun 14, 2005 2:02 am     Reply with quote

Can you help me to set up my pic18F452 in order to write on LCD display?My electric connections are:
Quote:
LCD Pic18F452
D0 D0
D1 D1
D2 D2
D3 D3
RS D4
RW D5
En A5

How can I modify the pin map structure of LCD.C to match this configuration?
Thank you
Guest








PostPosted: Tue Jun 14, 2005 4:26 am     Reply with quote

LCD PIC18F452
DB4 RD4
DB5 RD5
DB6 RD6
DB7 RD7
LCD_EN RD0
RW RD2
RS RD1

with this pin assignment u can use the posted code by chingB at http://ccsinfo.com/forum/viewtopic.php?t=23234&sid=53884f7160ba0e1a4696d801fbce3906
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 14, 2005 2:11 pm     Reply with quote

Quote:

Can you help me to set up my pic18F452 in order to write on LCD
display ? My electric connections are:
LCD Pic18F452

D0 D0
D1 D1
D2 D2
D3 D3
RS D4
RW D5
En A5

How can I modify the pin map structure of LCD.C to match this configuration?

To modify Mark's LCD driver for your pin map, you need to make
the changes shown below. Here is the link to Mark's driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=20182

You need to use the following lcd_pin_map structure:
Code:
struct lcd_pin_map

  int unusedA0_A4 : 5;  // Pins A0-A4 are not used
  BOOLEAN enable  : 1;  // Pin A5 = LCD Enable
  int unusedA6_A7 : 2;  // Pins A6,A7 are not used
  int unusedB;          // Port B is not used
  int unusedC;          // Port C is not used
  int     data : 4;     // Pins D0-D3 = LCD Data (LCD pins DB4-DB7)
  BOOLEAN   rs : 1;     // Pin D4 = LCD rs
  BOOLEAN   rw : 1;     // Pin D5 = LCD rw
  int unusedD  : 2;     // Pins D6,D7 are not used
} lcd;


The TRIS map must also be changed to the following:
Code:
struct lcd_tris_map
{
int unusedA0_A4 : 5;   // Pins A0-A4 are not used
BOOLEAN enable  : 1;   // Pin A5 = LCD Enable
int unusedA6_A7 : 2;   // Pins A6,A7 are not used
int unusedB;           // Port B is not used         
int unusedC;           // Port C is not used
int data    : 4;       // Pins D0-D3 = LCD data (LCD pins DB4-DB7)
BOOLEAN rs  : 1;       // Pin D4 = LCD rs
BOOLEAN rw  : 1;       // Pin D5 = LCD rw
int unusedD : 2;       // Pins D6-D7 are not used
} lcdtris;


The set_tris_lcd() macro must be changed to this:
Code:
#define set_tris_lcd(x) lcdtris.data = (x); \
                        lcdtris.rs = 0; \
                        lcdtris.rw = 0; \
                        lcdtris.enable = 0;


Important Note:
When you operate the LCD in 4-bit data bus mode, it's the upper 4 bits
of the LCD data bus that are used -- pins DB4 to DB7. So you must
connect the LCD data pins to the PIC as follows:
Code:

LCD pin     PIC pin
DB4           D0
DB5           D1
DB6           D2
DB7           D3
Silver



Joined: 10 Jun 2005
Posts: 4
Location: Italy

View user's profile Send private message

PostPosted: Wed Jun 15, 2005 10:17 am     Reply with quote

Thank you for the code!!! Now my lcd works properly
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