chipKIT® Development Platform

Inspired by Arduino™

I2C2 on Max32

Created Tue, 29 Apr 2014 13:48:35 +0000 by Ian Billing


Ian Billing

Tue, 29 Apr 2014 13:48:35 +0000

The I2C on Max32 is mapped to use SDA1/SCL1. Is it possible to remap it so that SDA2/SCL2 is used instead? I see the mapping that refers to I2C in Board_data.c but am not sure what to change there.

or maybe:

If I change all of the references from I2C1 to I2C2 will that ensure the use of SDA2/SCL2 by the wire library?

/* ------------------------------------------------------------ / / I2C Port Declarations / / ------------------------------------------------------------ */

/* The standard I2C port uses I2C1 (SCL1/SDA1). These come to digital ** pins 20 & 21 on the communications connector (J4) */ #define _TWI_BASE _I2C1_BASE_ADDRESS #define _TWI_BUS_IRQ _I2C1_BUS_IRQ #define _TWI_SLV_IRQ _I2C1_SLAVE_IRQ #define _TWI_MST_IRQ _I2C1_MASTER_IRQ #define _TWI_VECTOR _I2C_1_VECTOR #define _TWI_IPL_ISR _I2C1_IPL_ISR #define _TWI_IPL _I2C1_IPL_IPC #define _TWI_SPL _I2C1_SPL_IPC


EmbeddedMan

Tue, 29 Apr 2014 17:21:19 +0000

Yes, I think it you simply change all of the references from I2C1 to I2C2 and recompile, it should use the 2nd I2C port.

*Brian


Ian Billing

Wed, 30 Apr 2014 05:28:33 +0000

Thanks. I changed those references but still do not get the second I2C por to work. Are there other mappings that also need to be changed?


EmbeddedMan

Wed, 30 Apr 2014 06:43:21 +0000

I don't think so. Are you sure that the I2C2 port comes out? I mean, looking at the schematic, do you need to set any jumpers or anything to get access to those pins?

*Brian


Ian Billing

Wed, 30 Apr 2014 07:05:37 +0000

Looking at the schematic and the board layout the SCL2/SDA2 go straight to pins 12 and 13 and that agrees with the pin outs listed in the Max32 data sheet. But still not working!


EmbeddedMan

Wed, 30 Apr 2014 07:18:28 +0000

Remember that pin 13 also has an LED on it.

Do you have pull-ups on both lines? And can you see them wiggle at all on a scope? Or are they completely dead?

*Brian


EmbeddedMan

Wed, 30 Apr 2014 07:27:36 +0000

I just tried it with my MAX32 and it works for me. I'm getting valid I2C data out pins 12 and 13 when I switch over the #defines as above. Now, because of the LED on 13, the SDA2 pin only rises to about 1.0V (with a 3.3V pullup). So that may cause you problems. You probably want to unsolder the current limiting resistor on pin 13's LED.

*Brian


Ian Billing

Wed, 30 Apr 2014 08:14:07 +0000

That's was exactly it!!!! Thanks so much.