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 PORTD/16F877

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







LCD PORTD/16F877
PostPosted: Mon Mar 03, 2003 6:18 am     Reply with quote

<font face="Courier New" size=-1>What do I need to change to make it to work on portD, as of now it is not working. This LCD has HD44780A00 controller.

LCD PIN OUT
1--GND
2--VCC
3--VEE--contrast
4--RS
5--R/W
6--E
7--14--DB0--DB7




// As defined in the following structure the pin connection is as follows:
// D0 enable
// D1 rs
// D2 rw
// D4 D4
// D5 D5
// D6 D6
// D7 D7
//
// LCD pins D0-D3 are not used and PIC D3 is not used.

// Un-comment the following define to use port B
// #define use_portb_lcd TRUE


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
#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

#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


byte CONST LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};
// These bytes need to be sent to the LCD
// to start it up.


// The following are used for setting
// the I/O port direction register.

STRUCT lcd_pin_map const LCD_WRITE = {0,0,0,0,0}; // For write mode all pins are out
STRUCT lcd_pin_map const LCD_READ = {0,0,0,0,15}; // For read mode data pins are in




byte lcd_read_byte() {
byte low,high;
set_tris_lcd(LCD_READ);
lcd.rw = 1;
delay_cycles(1);
lcd.enable = 1;
delay_cycles(1);
high = lcd.data;
lcd.enable = 0;
delay_cycles(1);
lcd.enable = 1;
delay_us(1);
low = lcd.data;
lcd.enable = 0;
set_tris_lcd(LCD_WRITE);
return( (high<<4) | low);
}


void lcd_send_nibble( byte n ) {
lcd.data = n;
delay_cycles(1);
lcd.enable = 1;
delay_us(2);
lcd.enable = 0;
}


void lcd_send_byte( byte address, byte n ) {

lcd.rs = 0;
while ( bit_test(lcd_read_byte(),7) ) ;
lcd.rs = address;
delay_cycles(1);
lcd.rw = 0;
delay_cycles(1);
lcd.enable = 0;
lcd_send_nibble(n >> 4);
lcd_send_nibble(n & 0xf);
}








</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12303
ISAAC AIYANYO
Guest







Re: LCD PORTD/16F877
PostPosted: Thu Aug 21, 2003 10:50 am     Reply with quote

:=<font face="Courier New" size=-1>What do I need to change to make it to work on portD, as of now it is not working. This LCD has HD44780A00 controller.
:=
:=LCD PIN OUT
:=1--GND
:=2--VCC
:=3--VEE--contrast
:=4--RS
:=5--R/W
:=6--E
:=7--14--DB0--DB7
:=
:=
:=
:=
:=// As defined in the following structure the pin connection is as follows:
:=// D0 enable
:=// D1 rs
:=// D2 rw
:=// D4 D4
:=// D5 D5
:=// D6 D6
:=// D7 D7
:=//
:=// LCD pins D0-D3 are not used and PIC D3 is not used.
:=
:=// Un-comment the following define to use port B
:=// #define use_portb_lcd TRUE
:=
:=
:=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
:=#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
:=
:=#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
:=
:=
:=byte CONST LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};
:= // These bytes need to be sent to the LCD
:= // to start it up.
:=
:=
:= // The following are used for setting
:= // the I/O port direction register.
:=
:=STRUCT lcd_pin_map const LCD_WRITE = {0,0,0,0,0}; // For write mode all pins are out
:=STRUCT lcd_pin_map const LCD_READ = {0,0,0,0,15}; // For read mode data pins are in
:=
:=
:=
:=
:=byte lcd_read_byte() {
:= byte low,high;
:= set_tris_lcd(LCD_READ);
:= lcd.rw = 1;
:= delay_cycles(1);
:= lcd.enable = 1;
:= delay_cycles(1);
:= high = lcd.data;
:= lcd.enable = 0;
:= delay_cycles(1);
:= lcd.enable = 1;
:= delay_us(1);
:= low = lcd.data;
:= lcd.enable = 0;
:= set_tris_lcd(LCD_WRITE);
:= return( (high<<4) | low);
:=}
:=
:=
:=void lcd_send_nibble( byte n ) {
:= lcd.data = n;
:= delay_cycles(1);
:= lcd.enable = 1;
:= delay_us(2);
:= lcd.enable = 0;
:=}
:=
:=
:=void lcd_send_byte( byte address, byte n ) {
:=
:= lcd.rs = 0;
:= while ( bit_test(lcd_read_byte(),7) ) ;
:= lcd.rs = address;
:= delay_cycles(1);
:= lcd.rw = 0;
:= delay_cycles(1);
:= lcd.enable = 0;
:= lcd_send_nibble(n >> 4);
:= lcd_send_nibble(n & 0xf);
:=}
:=
:=
:=
:=
:=
:=
:=
:=
:=</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144517132
ISAAC AIYANYO
Guest







Re: LCD PORTD/16F877
PostPosted: Thu Aug 21, 2003 10:52 am     Reply with quote

I have got a similar problem using the same conections on portD of pic16f877
Did you ever get it working?

Isaac
___________________________
This message was ported from CCS's old forum
Original Post ID: 144517133
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