View previous topic :: View next topic |
Author |
Message |
sshahryiar
Joined: 05 May 2010 Posts: 94 Location: Dhaka, Bangladesh
|
PCF8574 I2C 8-bit Port Expander Driver |
Posted: Wed Apr 10, 2013 10:37 pm |
|
|
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
|
|
Posted: Mon Apr 29, 2013 3:09 pm |
|
|
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
|
Regarding device address. |
Posted: Mon Apr 29, 2013 11:22 pm |
|
|
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
|
Re: Regarding device address. |
Posted: Tue Apr 30, 2013 8:11 am |
|
|
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
|
|
|
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Tue Apr 30, 2013 1:29 pm |
|
|
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
|
|
|
kaiyara
Joined: 04 Jul 2013 Posts: 1 Location: Banned - spammer
|
|
Posted: Thu Jul 04, 2013 6:27 am |
|
|
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
|
Port expander or RTC? |
Posted: Thu Jul 04, 2013 10:09 am |
|
|
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 |
|
|
|