|
|
View previous topic :: View next topic |
Author |
Message |
rfjhh
Joined: 31 Mar 2011 Posts: 51 Location: Mexico
|
Constants |
Posted: Wed Mar 13, 2019 2:51 pm |
|
|
I am trying to modify the LCD420.c library to work with port D but I have found things that I do not understand:
How should I interpret the following sequence?
Code: | struct lcd_pin_map const LCD_READ = {0,0,0,0,15};
BYTE lcd_read_byte() {
BYTE low,high;
set_tris_d([b]LCD_READ[/b]);
.
.
.
. |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9255 Location: Greensville,Ontario
|
|
Posted: Wed Mar 13, 2019 6:45 pm |
|
|
my copy of the driver has this..
// 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
...
Note the //comment at the end. It makes 4 pins of the I/O data direction register (TRISx) to be inputs, thus allwoing the PIC to READ the data from the LCD module.
I would have preferred ... LCD_READ = {0,0,0,0,1,1,1,1}, as it 'shows' the format better, at least to me.
hope this helps
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Constants |
Posted: Wed Mar 13, 2019 7:25 pm |
|
|
rfjhh wrote: |
I am trying to modify the LCD420.c library to work with port D |
1. Change the following line:
Quote: | #locate lcd = getenv("SFR:PORTB") |
to this:
Code: | #locate lcd = getenv("SFR:PORTD") |
2. In the following routine, notice the two lines in bold:
Quote: | BYTE lcd_read_byte() {
BYTE low,high;
set_tris_b(LCD_READ);
.
.
.
.
.
set_tris_b(LCD_WRITE);
return( (high<<4) | low);
} |
Change them to:
Code: | set_tris_d(LCD_READ); | and
Code: | set_tris_d(LCD_WRITE);
|
3. In this routine, notice the line in bold:
Quote: | void lcd_init() {
BYTE i;
set_tris_b(LCD_WRITE);
lcd.rs = 0;
lcd.rw = 0;
|
Change it to:
Code: | set_tris_d(LCD_WRITE);
|
|
|
|
Jerson
Joined: 31 Jul 2009 Posts: 126 Location: Bombay, India
|
Re: Constants |
Posted: Wed Mar 13, 2019 8:39 pm |
|
|
rfjhh wrote: |
How should I interpret the following sequence?
Code: | struct lcd_pin_map const LCD_READ = {0,0,0,0,15};
set_tris_d([b]LCD_READ[/b]);
.
. |
|
LCD_READ is a structure mapped onto a byte value. the value shown is 0x0F. So, the statement set_tris_d(LCD_READ) will be seen as set_tris_d(0x0F) |
|
|
rfjhh
Joined: 31 Mar 2011 Posts: 51 Location: Mexico
|
Problem fixed |
Posted: Wed Mar 13, 2019 10:50 pm |
|
|
Thanks all of you, PCM specially, now it's working well. |
|
|
|
|
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
|