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 I2C address

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



Joined: 28 Mar 2019
Posts: 10

View user's profile Send private message

LCD I2C address
PostPosted: Mon Apr 08, 2019 2:32 pm     Reply with quote

Good morning, today my problem revolves around i2c communication; this is my problem:
I have a pic18f67k40 connected to a lcd i2c screen that works well but when buying another screen (apparently the same) I discovered that the address is different. Since I do not want to change the code depending on the manufacturer, I am thinking of performing a function that scans the address of the i2c screen to automatically incorporate it. The problem is that if I indicate the address inside the main function it does not work ... what can I do?
MarkchchPIC



Joined: 14 Jan 2015
Posts: 18
Location: Christchurch New Zealand

View user's profile Send private message

I2C Address
PostPosted: Mon Apr 08, 2019 2:41 pm     Reply with quote

Hi there we will need a lot more info to be able to assist you.
There is a wonderful piece of code from PCM in the library that can detect I2c devices and give their addresses.
This may be a way to sort your problem.
SQR-1



Joined: 28 Mar 2019
Posts: 10

View user's profile Send private message

PostPosted: Mon Apr 08, 2019 2:51 pm     Reply with quote

Thank you very much for the quick reply. I have already tried several functions that detect the i2c address and show it by serial port and they work ... but what I need is that it is automatic once it is detected, the address is assigned to the screen. If I assign the address at the beginning of the code everything works but I do not know how to assign it once the program is started.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 08, 2019 3:27 pm     Reply with quote

What driver are you using for your i2c lcd ? It is this one in the CCS code library:
"Flexible I2C LCD driver (PCF8574T) by Hugo Silva" -
http://www.ccsinfo.com/forum/viewtopic.php?t=54063

Notice that he sets the lcd slave address here:
Code:
#define LCD_ADDR      0x4E        //I2C slave address for LCD module 

You need to comment out the line above.

Then add this line:
Code:
int8 LCD_ADDR = 0x4E;  // Default lcd i2c addr

Then you need to modify the i2c bus scanner code so you take the address
that is found and put it into the 'LCD_ADDR' variable. Normally we don't
use all caps for variables, but it would make it easier if left it that way.
Then you only need to add the int8 LCD_ADDR line shown above and
comment the #define. You don't have to do anymore edits.

If you have more than one i2c device attached to that bus, I suggest that
you use a separate bus for the lcd, with only the lcd on it. Then running
the i2c scanner program on that bus will only find the lcd.
empty



Joined: 13 Jan 2018
Posts: 15

View user's profile Send private message

PostPosted: Tue Apr 09, 2019 2:05 am     Reply with quote

You should give us some details so we can help you!
If your LCD is connected to PCF8574/PCF8574A then the address will depend
on the connection of A2, A1, A0 pins (read device datasheet for more information).

PCF8574 address = 0 1 0 0 A2 A1 A0 0

PCF8574A address = 0 1 1 1 A2 A1 A0 0
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