3

I use SWD for load firmware in stm32 chip and debugging. It uses 3 pins: SWCLK(TCK), SWDIO(TMS) and GND.

Can I use other JTAG pins, that not used in SWD interface: (TDI, TDO, TRST) for own purposes while preserving the possibility of flashing firmware in chip?

kaliczp
  • 457
  • 1
  • 12
  • 18
user3583807
  • 766
  • 1
  • 8
  • 26

5 Answers5

8

Actually SWD uses only two pins SWD & SCLK. GND's are common and cant be used for any other purposes. SWO - only if you use (and need) features like semihosting

If you run CubeMx - you will see that if you select SWD, all other JTAG pins become available for the general use.

0___________
  • 60,014
  • 4
  • 34
  • 74
1

Well, it might depend on the capabilities of you debugger....

But in general: Yes, you can do the flash programming just via SWD and use the JTAG pins left over for other purposes. E.g. a Lauterbach debugger can do it.

However, if your debugger-tool supports trace recording, I would not use the TDO pin for your application, since this pin can usually be used as the SWO trace pin in SWD mode. (with Cortex-M3/M4 or M7)

Holger
  • 3,920
  • 1
  • 13
  • 35
1

I just might add that you can always connect to stm32 with JTAG or SWD if you select in the debugger settings connect under reset.
This is necessary when you reconfigure intentionally or unintentionally the JTAG or SWD pins. However it also depends on the hardware attached to these pins so sometimes it won't work.
Nevertheless it should be sufficient for loading the firmware.

phodina
  • 1,341
  • 1
  • 12
  • 25
1

After the reset the uC will be ready to connect either thru SWD or JTAG, is all up to your debugger (as all pins will be in the default config), but when your application reconfigure one of the IOs used by the debug interface you loose the hability to connect to the core thru this interface.

If you dont use any of the SWD pins (CLK and DIO) you will be able to connect to your target at any time without even reseting the uC, as these pins will be ready to connect at any time

but, if you reconfigured one of these pins to, for example, read a pushbutton, you will need to reset the target and connect to it before your code runs, in this case you will need to add to the debug interface the connection to the RESET pin, so the debugger resets the target and connect to it right after. (and obviously, you cannot push the button during debug) thats why is always useful to add the RESET to the debugger connection

Gustavo Laureano
  • 556
  • 2
  • 10
0

Yes you can use other JTAG pins. And if you don't need debugging you can also use SWD pins after flashing chip, but in these case you will most likely need to boot from system memory for chip reprogramming.

Yuriy
  • 701
  • 4
  • 18