Skip to content

SAMD outputs do not provide high drive current #5258

@MLXXXp

Description

@MLXXXp

The documentation for the Zero and MKR1000 both state:
DC Current per I/O Pin 7 mA

However, according to the ATSAMD21G18 datasheet, this current is only available if the Output Driver Strength bit (DRVSTR) for the pin has been set to 1. Otherwise, the pin can only source a maximum of 2 mA or sink 2.5 mA. I can't find anywhere in the Arduino source code that sets the DRVSTR bit for a pin. Even if it is being set somewhere that I missed, the line
PORT->Group[g_APinDescription[ulPin].ulPort].PINCFG[g_APinDescription[ulPin].ulPin].reg=(uint8_t)(PORT_PINCFG_PULLEN) ;
which is always executed in function digitalWrite() in file wiring_digital.c will clear DRVSTR.

Therefore, at best, the documentation is misleading.

Ways I see to address the problem:

  • Change the documentation to state that only 2 mA is available unless the user writes code to manipulate the I/O output pins directly to get 7 mA, bypassing the Arduino digital pin functions. This would probably be difficult at this point. Even SparkFun and Adafruit state the higher current for their ATSAMD21 products.
  • 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.
  • Add a new mode to the pinMode() function, such as OUTPUT_HIGH_CURRENT, to be used instead of OUTPUT when high drive capability is desired. In addition to changing the pinMode() function, the digitalWrite() function would also have to be modified to not change DRVSTR, as was described above.

And just a side note:
That same line quoted above that sets PULLEN, also clears INEN (in addition to DRVSTR), nullifying INEN having been set in pinMode(x, OUTPUT). Therefore, reading the IN register will not provide the state of the output pin after a digitalWrite().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions