In short, what is the maximum bitrate that can be achieved writing to an I2C bus from a Raspberry Pi? Should it be the theoretical maximum of 100KB/s?
In more detail, I'm writing to an I2C bus from my Pi, sending messages to 10 PWM microcontrollers, each with 16 channels. (The model is Adafruit's PCA9685).
I'd like to be able to update these registers at something like 10-20Hz. Each channel has a 2-byte register, so naively I'd expect that to equate to 16 * 10 * 20 = 3.2KB/s. That's well within the protocol's limit of 100KB/s.
However, when I try to drive these microcontrollers from a Python script running on my Pi, I'm only able to achieve about 2Hz update frequency; I've profiled the code and most of the time spent is in the library that's actually calling out to the /dev/i2c* device.
I'm wondering if there's a hardware or driver restriction that limits the bitrate?
I'm using a 1st generation model B, Raspbian version 2015-02-16.
strace
on that; if you are using thesmbus
library this may be stretching the bounds of what it is intended for (what you are doing sounds more like it would require a kernel driver of its own, or something that bypasses the kernel viammap
, such as the wiringPi stuff). The generic smbus library would be making a system call for every write.