In the sample program for the PCF8574, the address for the PCF8574 is shown as 0x20. The PCF8574 has a base address of 0x40 ( and the 74A has a base address of 0x70)
I've wired up a PCF8574 and the sample program works if you change the 0x20 to 0x40
Also, the comments indicate that the code toggles the pins. Actually, since the value sent out is only 0x0f, only port pins 0-3 actually toggle. Changing the value to 0xff makes them all toggle.
The sample is probably using the old version of library where the address was 7 bits. In the current version the address is 8 bits, including the r/w bit.
See here for details.
Thanks Igor. I've just started playing with my new mbed 4 hours ago, so wasn't aware of the old library. Having worked with I2C peripherals using AVR chips etc., I know that the LSB is the R/W bit, and figured that this probably the cause of the mixup. I think I'll be trying Microchip's MCP23016 16 bit I/O expander next.
Looks to me like the ARM chip/mbed environment/board is going to be great! Even after only a few hours on the site, I can see that you are one of the experts!
Please log in to post a reply.
mbed, the fastest way to prototype with ARM based microcontrollers.
^ back to top