Max Current for Digital Pins: Is it limited by the board?

When I first aquired my mkr wifi1010 I ran across this post discussing the "drive strength" of the pins on the samD boards.

Apparently there is a bit in a register that sets the drive strength of the pins to be either 7mA or ~ 2.5mA depending on whether it is set or not. By default it is set to the lower limit on arduino boards even though it is not mentioned anywhere.

The last post in the thread sums it up:

@MartinL
By default the DRVSTR (driver strength) bit isn't set in the Arduino SAMD core code, therefore the GPIO pins operate in low current mode and are able to source 2mA and sink 2.5mA.

To increase a given pin's driver strength and allow it to source 7mA and sink 10mA, just add the following line after calling the pinMode() function. In this example the driver strength of digital pin D7 is increased:

PORT->Group[g_APinDescription[7].ulPort].PINCFG[g_APinDescription[7].ulPin].bit.DRVSTR = 1;

Subsequent calls to the digitalWrite() function don't affect the DRVSTR bit in any way.

I wrote this function to test this for myself:

void pinModeStrong(uint8_t pin, uint8_t mode) {
  pinMode (pin, mode);
  PORT->Group[g_APinDescription[pin].ulPort].PINCFG[g_APinDescription[pin].ulPin].bit.DRVSTR = 1;
}

Tested using the backlight on an Oled there certainly was a major difference in brightness. I did not measure the actual current myself.

This suggests that there must be some form of current limitation at least in the default low current mode. Maybe @pert would know for sure.

2 Likes