adamhayes wrote:Thanks, Mike.
I now have the pins turning on and off, but I would like to set the maximum current using those registers. Is there some simple (shell script?) way to set those bits? I've never tried to set registers before.
Note that the GPIO pins are in three groups or 28 pins so all the pins we're interested in are in the first group, so you can't control the drive for a single pin, but essentially all the pins on the GPIO connector.
The 3 sets of pad drivers are initialised to:
0000001B 0000001F 0000001B
the 0x1B is the ones we're interested in for GPIOs 0-27 and decoding 0x1B into 0001 1011 gives us
slew: 1 - not limited
hyst: 1 - enabled
drive: 011 - 8mA
So in theory we can change drive to 111b (7) and get it up to 16mA.
Now.. I'm not a chip designer and it'll take someone who is (pref. from broadcom!) to explain exactly how the current limiter works, but I know that using the Pi, it's possible to drive LEDs at 15mA using the defaults... Actually, I know that a single GPIO pin will source 35mA if you accidentally short an LED limiting resistor with a DVM set to amps and not volts... My suspicion is that there is an overall current limiter for all the pads in the group, so taking a little more on one pin isn't going to have any effect unless you do it on all of them...
Note the 2nd group is enabled for 16mA drive... The chip reset condition is for 8mA, so something in the kernel has explicitly set that group for higher drive current... A quick look at the schematic shows thos pins in that group being used for the PWM/Audio outputs only.
I did experiment with it in wiringPi, but in the end never really bothered doing anything with it. I suspect that for the most part it's not going to be an issue, but it's easy to change if you need to - some of the code is there in wiringPi, but commented out if you look close enough...