Prelude
to copy the definition of the JTAG, SW interface,
Jtag:jtag (Joint test Action Group; joint testing team) is an international standard test protocol that is used primarily for in-chip internal testing. Most advanced devices now support JTAG protocols such as DSPs, FPGA devices, and so on. The standard JTAG interface is 4 lines: TMS, TCK, TDI, TDO, mode selection, clock, data input, and data output lines, respectively.
SWD:SW (Serial wire mode Interface), serial interface pattern. In serial line mode, only the pin TCLK and TMS are used. The TDO data output pin is an optional.
SWD download and debug schematic diagram:
See: The board uses the SWD interface to download debugging, that is, the use of Swdio, SWCLK (PA13, PA14); the pb3–jtdo default function is Jtag, and here is used for other functions – normal I/O.
Passion
Here's the problem:
1, need to turn off the PB3 jtag function, re-use for other functions.
2, SWD and the traditional debugging mode difference.
Stm32 Jtag Multiplexing Related methods:
Directly on the code, as follows:
........ | RCC_APB2Periph_AFIO, ENABLE); //改变指定管脚的映射 GPIO_Remap_SWJ_JTAGDisable JTAG-DP 失能 + SW-DP使能 GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); .......
But
When the above statement is set, the JTAG emulation loses contact with the target when both statements are run.
The solutions are:
1. Set boot mode to ISP mode (boot0=1, boot1=0) or set boot mode to RAM run mode (boot0=1, boot1=1). When the board is powered off, it is not in the user program mode, so the JTAG-disabled statement is not executed, and the JTAG function can be used normally.
2, set the startup mode for the ISP mode (boot0=1, boot1=0), with the ISP program will STM32 Flash erase, after the JTAG function can be restored.
3, if your emulator supports the SWD simulation mode, such as the IAR under the Jlink, MDK with ULINK2. By setting the emulator mode directly to the SWD module, you are not affected by this forbidden Jtag function.
My environment fits the third solution, and the IAR settings are as follows:
SWD differs from traditional debugging methods:
- The SWD mode is more reliable than JTAG in high-speed mode. In the case of large data volumes, the JTAG downloader fails, but the chances of SWD happening are much smaller. The basic use of JTAG emulation mode is that you can use the SWD mode directly, as long as your emulator supports it. So we recommend that you use this mode.
- You can use the SWD emulation when you have just one GPIO, which supports fewer pins.
- In the board of the size of a limited time recommended to use the SWD mode, it requires less pins, of course, the PCB space required is small! For example, you can choose a small 2.54-pitch 5-pin terminal to do the simulation interface.
And then
Above
Scattered ...
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
STM32 JTAG pin multiplexing settings