Some bizarre power up I2C behavior from Mega. Uno tests OK. What gives?
I have an application where I power a Mega by 9V external supply to the Vin pin. At power up, I expect the Mega to activate selected outputs on an MCP23017 I/O expander IC used as an LED driver. When I apply power to the circuit, the Mega activates the IC, so the I2C addressing is working, but the outputs are garbled ( usually dumps all the signals to the lowest output on the IC ), then it hangs. I have learned the following:
-
Using an Uno instead of a Mega in the circuit works correctly every time.
-
Pressing the reset button makes it work correctly.
-
No amount of delays or I2C.begin/end/speed/pullup calls seems to fix the problem.
-
All diagnostics from the I2C library show no errors.
-
Putting a 1800uF capacitor between Vin and ground effects the garbled output but does not correct it.
-
Signal levels on the MCP23017 are correct.
I can work around the problem by using an Uno instead of the Mega. Also, forcing a software reset on power up corrects the output, but it is not clear to me how to set up a one-shot software reset for this application, except by flipping a bit in the Mega's EEPROM, which has some limitations.
If it was a timing issue, you would think a delay would work, since a simple reset does the trick. It seems to me that, with respect to I2C at least, the Mega does not power up on Vin to the same state as after a manual reset, as the Uno appears to.
Anybody have any info on this? I recall some threads on this problem, but I can't seem to find them.