Are the Zero's pins set to strong drive strength by default?

I noticed Mattairtech's pin definitions include PER_ATTR_DRIVE_STRONG on them. But in googling that, the only reference I find to that constant is on Mattairtech's own page.

I know the Zero's specs state 7mA is the max per pin, but I also know that the SAMD21 has two different drive strengths you can specify and only the strong drive strength allows for 7mA per pin. But what I don't know is where I would look in the Zero's source to verify that the pin drive strength is actually being set properly.

I also just searched for references to the register to set drive strength and I found this:

So it would appear that as I feared, the specs for the Zero that state the pins can source/sink 7mA are incorrect or at least, misleading as things are currently configured.

Quote from github:

Change the code to always set outputs to high drive mode. Since in many cases high current isn't required, this could unnecessarily increase the chances of causing hardware damage due to shorted outputs.

What does he mean by increase the chances of causing hardware damage?

I would assume that enabling the high drive mode would lessen the chances of causing hardware damage, as the danger of damaging the hardware would come from drawing more current from the pin than it is able to supply.

In other words, if you connect an LED to the pin and are drawing 7mA but the pin is set to 3mA then the pin isn't going to limit the current to 3mA. It's going to supply as much current as your resistance dictates, and if that is 7mA, and the pin is not set to high drive mode, then the pin may be damaged.

I assume high drive mode enables a second FET inside the chip or something to allow for the higher current, and this in turn results in a higher quiescent current which is why you might not want this enabled all the time if you are doing low power stuff. But I don't understand it 100% yet so I could be wrong.

The Zero's "wiring_digital.c" file that performs the digitalWrite() and digitalRead() functions, does not set the DRVSTR bit in the PINCFG (pin config) register, that provides increased drive strength. Also, even if you set this bit, digitalWrite() it will reset DRVSTR back to 0.

If you need the higher drive strength, then it's necessary to manipulate the port registers directly.


these seem to be the only two pins with the DRVSTR register set by default

Okay, but I agree with the person who posted that bug Github. If the specs listed everywhere for the Zero state that the IO pins are capable of handling 7mA, then the default absolutely should be that they have high drive strength enabled by default. It is also just better to have to have it enabled because it provides an extra measure of protection for newbies who may not even realize the current handling capability is lower than your typical Arduino. There are, after all, a lot of old tutorials out there that they will find that don't make a distinction between the Uno and Zero.

And if someone wants to change that setting for a particular pin so they can reduce the current draw, then make a command for that, and maybe add a preprocessor directive to choose to default if they always want to default to low current.

I agree.

I gave up using the Zero’s digtal read and write a while ago. The implementation has had a number issues that are simple fixes, but have never been addressed. For example the insistance of digtalWrite() to unnecessarily activate the pull-up resistor and the fact that unlike the AVR Arduinos, it’s still not possible to read back your own output, which can sometimes be useful.

Not activating the DRVSTR bit is just another to add to the list.

Has there been any conclusion on this?

Reading through this post is sounds like it may still be an issue?

I would just like to know if I do pinMode(pin#, OUTPUT)

and then a digitalWrite, is DVRSTR set at 1 or 0? In other words is the pin drive strength set to stronger?

Hi aehrlich54,

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.