P2 with MCP39F521

I have been trying to get the Smart Plug demo project tutorial to work - using an MCP39F521 demo board with a P2 Eval board to read power (and other things). Unfortunately, I have hit the problems with Wire /I2C that others have hit: I2C requestFrom gives 0 available bytes and MCP32F521 Library Port to Particle now both closed threads. Just wondering if the tutorial did actually work and if it did, what was the secret sauce to allow I2C comms with the MCP39F521? All my attempts result in C5 FF FF…FF being read back from this IC.


Just came across this as the notification email got delivered to my "Promotions" folder/tab!

I had specified the workaround I used in the I2C requestFrom gives 0 available bytes thread - see around Sept 22. I had to either call requestFrom twice (the first time with a small timeout), or call Wire.reset after endTransmission. From my investigation, the I2C_FLAG_BUSY was never getting reset, causing the protocol to hang. Called requestFrom with the small timeout, or the Wire.reset helped to clear the flag and keep things moving. The problem appeared to trickle down to deeper within HAL code and I couldn't dig down the source of the bug.

Hope that helps!

@sridhar_rajagopal Many thanks - I will try that out.

I haven't retried with the latest Device OS for P2, I know there have been fixes for I2C.