IIC is a curiously complicated protocol. I say curiously because on first glance it looks simple, one serial data line, one clock line, that’s it. How hard can that be? Then we have multiple masters, bus capacitance, addressing, acknowledging, repeated start conditions, 2 addressing standards and some other baud rate standards and it gets fun.
All these characteristics will make MCU IIC peripherals complicated. Not straightforward like a common UART or a timer (although I have my thoughts on timers, being a motor control enthusiast, reserved for a future post). Anyway, IIC is a fun little protocol (where fun is defined as jerking off your already scarce hair at 11 P.M.)
Some time ago a customer inquired about using the IIC module. The basic premise: everything works ok, but I’d like to use it better. This was confusing, upon asking if he was able to communicate with the target device, he said he was, he had no problem communicating to the device, writing and reading data, etc. So what was the problem? He said he wanted to use the hardware, this was still confusing, if you are communicating, you are using the hardware, right? Wrong! He meant the actual IIC hardware module. Turns out he had written a software, bit banged IIC driver in desperation of not getting the hardware module to work as he expected. The IIC protocol is funny in that it is simple to understand but then implementing it in silicon is not as much fun because of all the possible cases. This guy just understood the concept easier than he could understand the workings of the hardware module, so he went ahead and wrote his software IIC module, which worked fine, the only reason he wanted to use the hardware module was to reduce CPU overhead (which is why the module is there in the first place, OK, that and saving on external hardware, but that’s an entirely separate discussion).
I went ahead and explained the module, sent him some code similar to the one I mentioned in my “On loop and other nuances” post and sent him on his way. That left me thinking about a lot of things: documentation, enablement, usability, and softcores. I’ll eventually talk about those things, but meanwhile, what do you think? Should MCU modules be hard to use? Does it make sense for silicon vendors to invest time, money and silicon in making easy to use peripherals? Is it better spent doing enablement and documentation if this saves on silicon?