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

Constants

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



Joined: 31 Mar 2011
Posts: 51
Location: Mexico

View user's profile Send private message

Constants
PostPosted: Wed Mar 13, 2019 2:51 pm     Reply with quote

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: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 13, 2019 6:45 pm     Reply with quote

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

View user's profile Send private message

Re: Constants
PostPosted: Wed Mar 13, 2019 7:25 pm     Reply with quote

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: 121
Location: Bombay, India

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

Re: Constants
PostPosted: Wed Mar 13, 2019 8:39 pm     Reply with quote

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

View user's profile Send private message

Problem fixed
PostPosted: Wed Mar 13, 2019 10:50 pm     Reply with quote

Thanks all of you, PCM specially, now it's working well. Laughing
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