SAMD21 usage of SWDIO and SWCLK pins

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I would like to use pins SWDIO and SWCLK as general I/Os and am not sure if it is possible.

Can these pins for example drive NPN or PNP transistor through some resistor (10k) without losing the ability to reprogram/debug the device ?

Can these pins also be used as digital inputs if driven through some resistor (10k) ?

Is the value 10k sufficient or should it be higher ?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The SWCLK pin must be high during reset (or else the chip goes into debugging mode), so it is probably not a good idea to use it as an input. The Schematic Checklist section of the data sheet says it should be pulled up with 1k.

 

Otherwise, on reset the multiplexer for the SWCLK pin is set to be used for debugging, but you can change it to be used as a port pin or even a SERCOM pin, etc.  The SWDIO pin starts off as a port pin and likewise can be multiplexed to other uses.  Using either as outputs shouldn't be a problem as long as it doesn't matter that those pins toggle during program & debug (what will your transistor be turning on and off at 2MHz?).  Using SWDIO as input shouldn't be a problem with an input resistor of 10k, the chip can easily drive over that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you DosMan for detailed answer. Very helpful.

I wasn't aware of the recommended pullUp on SWCLK; I made several samples of custom board without the pullUp and during 3 months working on it (restarted hundred times) haven't noticed any start-Up failure.

I worked with PIC microcontrollers before, where PGC and PGD pins are supposed to be without any pull-up/down..

 

Last Edited: Wed. Jul 11, 2018 - 07:16 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I forgot to mention that the debug port supports "hot-plugging", which means entering debug mode when NOT in reset.  I assume this is how "Attach to Target" on the Debug menu of Atmel Studio works.  Once you set the pin mux on SWCLK to be something other than the debugger, hot-plugging will not work.

 

I suspect the recommendation for the small pull-up on SWCLK may be overkill.  The data sheet says: 

At startup, SWCLK is internally pulled up to avoid false detection of a debugger if SWCLK is left unconnected.

Maybe in a high-noise environment they found their internal pull-up could be too weak. Or if they really mean the pull-up is only there on start-up, you would need to have one full time to prevent entering debug mode through hot-plugging detection.  You could check their pull-up by measuring the voltage on the SWCLK pin with no load and a light external (pull-down) load. Now I'm curious and I can't easily measure it on my designs because the 1k pull-up is installed.