Software I2C on pins other than PIO0_10 and PIO0_11

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Software I2C on pins other than PIO0_10 and PIO0_11

1,000 Views
rikje888
Contributor II

Dear,

I am working on an application for an LPC812. This chip has only one I2C bus, but my application needs two. To resolve this problem I have implemented a software I2C bus.
During development, I have used pins PIO0_10 and PIO0_11. These are true open drain and are working fine (although the bitrate is quite slow, the slave device responds appropriately). However, now instead of using pins PIO0_10 and PIO0_11 I would like to use PIO0_13 and PIO0_17 for SDA and SCL respectively.
On my scope I can see that the bits are nicely send at the correct times and after the address is sent, the slave device (which is a AT24C32 EEPROM module) acknowledges. However, after the second byte, which signifies the address at which one wants to read or write, the slave does not acknowledges anymore. 
When I switch to a hardware I2C bus (just for testing), everything works just fine. This verifies that the hardware is not bricked and pull-ups are in place. 
When I hook up the slave device to PIO0_10 and PIO0_11 and use the software I2C (just for testing), everything works just fine. This verifies that the implementation of the software I2C bus is correct.
This leads me to believe that I am doing something wrong with the configuration of the pins. I have disabled pull-ups and pull-downs and enabled the opendrain (of which I know is not true open drain, but some approximation). Then I define the pins as outputs to be able to toggle the output voltage, and before the acknowledge is meant to be sent by the slave, I toggle the direction of the SDA pin to make it an input. 
#define SDA_PIN 13
#define SCL_PIN 17
...
   Chip_IOCON_PinSetMode(LPC_IOCON, SDA_PIN, PIN_MODE_INACTIVE);
   Chip_IOCON_PinSetMode(LPC_IOCON, SCL_PIN, PIN_MODE_INACTIVE);
   Chip_IOCON_PinEnableOpenDrainMode(LPC_IOCON, SDA_PIN);
   Chip_IOCON_PinEnableOpenDrainMode(LPC_IOCON, SCL_PIN);
   Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, SDA_PIN);
   Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, SCL_PIN);
Is there something I am missing here? Any help is welcome!
Thank you in advance.
Kind regards,
Rick Bouten
Labels (3)
0 Kudos
Reply
1 Reply

810 Views
rikje888
Contributor II

After quite some digging I found the issue.

It turns out that there is an enum available to specify which pin you want to configurate

That is why 

Chip_IOCON_PinSetMode(LPC_IOCON, SDA_PIN, PIN_MODE_INACTIVE);

instead has to be 

Chip_IOCON_PinSetMode(LPC_IOCON, IOCON_PIO13, PIN_MODE_INACTIVE);

which reference to the typedef enum CHIP_PINx in iocon_8xx.h

This made the ioconfig successful and everything work.

0 Kudos
Reply