Skip to content

SAMD outputs do not provide high drive current #5258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MLXXXp opened this issue Aug 17, 2016 · 1 comment
Closed

SAMD outputs do not provide high drive current #5258

MLXXXp opened this issue Aug 17, 2016 · 1 comment

Comments

@MLXXXp
Copy link

MLXXXp commented Aug 17, 2016

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants