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 CCS Technical Support

PCF8574 I2C 8-bit Port Expander Driver

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
sshahryiar



Joined: 05 May 2010
Posts: 94
Location: Dhaka, Bangladesh

View user's profile Send private message Send e-mail Visit poster's website

PCF8574 I2C 8-bit Port Expander Driver
PostPosted: Wed Apr 10, 2013 10:37 pm     Reply with quote

PCF8574.c

Code:
#define PORT_BASE_ADDRESS 0x40


unsigned char read_from_port();
void write_to_port(unsigned char data_byte);


unsigned char read_from_port()
{
    unsigned char port_byte=0;
    i2c_start();                             
    i2c_write((PORT_BASE_ADDRESS + 1));       
    port_byte=i2c_read(0);             
    i2c_stop();
    return port_byte;
}
                                               

void write_to_port(unsigned char data_byte)
{
    i2c_start();
    i2c_write(PORT_BASE_ADDRESS);
    i2c_write(data_byte);
    i2c_stop();
}

_________________
https://www.facebook.com/MicroArena

SShahryiar
fkl



Joined: 20 Nov 2010
Posts: 44

View user's profile Send private message

PostPosted: Mon Apr 29, 2013 3:09 pm     Reply with quote

Please tell me, I have a PCF8574А
respectively doing adjustments
Code:
#define PORT_BASE_ADDRESS 0x70
//A1=A2=A3=connect to GND

does not work
sshahryiar



Joined: 05 May 2010
Posts: 94
Location: Dhaka, Bangladesh

View user's profile Send private message Send e-mail Visit poster's website

Regarding device address.
PostPosted: Mon Apr 29, 2013 11:22 pm     Reply with quote

The first four bits of the device are fixed and so it is not possible to assign a address value of 0x70. If A2, A1 and A0 are connected to ground the legitimate address for PCF8574 is 0x40 and definitely not 0x70.
_________________
https://www.facebook.com/MicroArena

SShahryiar
fkl



Joined: 20 Nov 2010
Posts: 44

View user's profile Send private message

Re: Regarding device address.
PostPosted: Tue Apr 30, 2013 8:11 am     Reply with quote

sshahryiar wrote:
The first four bits of the device are fixed and so it is not possible to assign a address value of 0x70. If A2, A1 and A0 are connected to ground the legitimate address for PCF8574 is 0x40 and definitely not 0x70.

PCF8574A

error in hw (; PCF8574A was broken.
sshahryiar



Joined: 05 May 2010
Posts: 94
Location: Dhaka, Bangladesh

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Apr 30, 2013 8:24 am     Reply with quote

What do you mean by "Error in HW"?
_________________
https://www.facebook.com/MicroArena

SShahryiar
fkl



Joined: 20 Nov 2010
Posts: 44

View user's profile Send private message

PostPosted: Tue Apr 30, 2013 1:29 pm     Reply with quote

sshahryiar wrote:
What do you mean by "Error in HW"?

faulty PCF8574A
Another PCF8574A set and working.
sshahryiar



Joined: 05 May 2010
Posts: 94
Location: Dhaka, Bangladesh

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Apr 30, 2013 8:54 pm     Reply with quote

Good to know that.... Smile
_________________
https://www.facebook.com/MicroArena

SShahryiar
kaiyara



Joined: 04 Jul 2013
Posts: 1
Location: Banned - spammer

View user's profile Send private message

PostPosted: Thu Jul 04, 2013 6:27 am     Reply with quote

Thanks for sharing your code.
It would have been nice when you made more clear that your code only differs from the original version in the part where your code is 12hrs with AM/PM support where the original is 24hrs.
Also, why did you delete all the comments from the original version? Now your code is more difficult to understand.
_________________
Kai-banned-yara
sshahryiar



Joined: 05 May 2010
Posts: 94
Location: Dhaka, Bangladesh

View user's profile Send private message Send e-mail Visit poster's website

Port expander or RTC?
PostPosted: Thu Jul 04, 2013 10:09 am     Reply with quote

Firstly this post was about PCF8574 port expander and not about any RTC.

Secondly neither I know about any original code you are talking about nor have I copied anything from somewhere else. Whatever I did and posted here is completely by my own. You may feel similarities with other codes but since they all do the same tasks, they are ought to be similar, but not exactly the same.
_________________
https://www.facebook.com/MicroArena

SShahryiar
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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