当前位置:网站首页>SWD debugging mode of stm32

SWD debugging mode of stm32

2022-06-13 01:57:00 richardgann

We often use Jlink Downloader , One drawback of this Downloader is that it is used Jtag 20PIN Interface , Too many PIN Will lead to some small PCB The board is crowded , It will also increase the difficulty of wiring . While using SWD Interface download and debugging , Just use 4 individual PIN:  GND, RST, SWDIO, SWDCLK , And the download speed can reach 10M/s, The advantages are obvious .

SWD Brief description of simulation mode concept
 
One 、SWD It's different from traditional debugging
  • SWD Model than JTAG More reliable in high speed mode . In the case of large amounts of data JTAG The download will fail , however SWD It's much less likely to happen . Basic use JTAG In the case of simulation mode, it can be used directly SWD Mode , As long as your emulator supports . So I recommend you to use this mode .
 
  • In everyone GPIO Just when one is missing , have access to SWD Simulation , This mode supports fewer pins .
 
  • It is recommended to use when the size of the board is limited SWD Pattern , It needs fewer pins , Of course we need to PCB The space is small ! For example, you can choose a small one 2.54 Spaced 5 The core terminal is used as the simulation interface .
 

 
Two 、 The simulator is right SWD Mode support
 
1. Common simulators on the market are right SWD Mode support
 
        (1) JLINKV6 Support SWD Simulation mode , Slower .
        (2) JLINKV7 Better support SWD Simulation mode , The speed has been significantly improved , The velocity is JLINKV6 Of 6 times . 
        (3) JLINKV8 Very good support SWD Simulation mode , The speed can reach 10M.
        (4) ULINK1 I won't support it SWD Pattern .
        (5) Pirate ULINK2 Very good support SWD Pattern , Speed can reach 10M.
        (6) The original ULINK2 Very good support SWD Pattern , Speed can reach 10M.
 
2. SWD Differences in hardware interfaces
 
        (1) JLINKV6 The required hardware interface is : GND, RST, SWDIO, SWDCLK
        (2) JLINKV7 The required hardware interface is : GND, RST, SWDIO, SWDCLK
        (3) JLINKV8 The required hardware interface is : VCC, GND, RST, SWDIO, SWDCLK ( notes : Here are some for my own use JLINKV8 And the corresponding experimental results )
        (4) ULINK1 I won't support it SWD Pattern


        (5) Pirate ULINK2 The required hardware interface is : GND, RST, SWDIO, SWDCLK
        (6) The original ULINK2 The required hardware interface is : GND, RST, SWDIO, SWDCLK
 
    From this we can see that only JLINKV8 need 5 One pin , One more VCC Pin , The advantage is that : The simulation of the target board by the simulator needs RST Pin , Use the inside of the simulator VCC This function is not very wonderful . therefore ,JLINKV8 You have chosen to share only with the target board GND, But not altogether VCC. So I think this model is the most reasonable , Of course, usually the emulator and the target board share GND and VCC There's nothing wrong with it .
 
3、 ... and 、 stay MDK in SWD Mode settings
 
    When debugging the simulation, use J-LINK Of Cortex-M3 The way is enough , And in MDK His function has been done very well , Using standard 20 Foot's JTAG download , The speed is very fast , This is what most beginners do . however SWD The way seems to be faster 、 It is more convenient 、 Simple and direct 、, Strict requirements for board space in the project 、I/O It is more beneficial to users who are short of oral resources , natural JTAG need 20 Pin , and J-Link Of SWD It only needs 2 Root line (PA13/JTMS/SWDIO、PA14/JTCK/SWCLK) That's enough ( Add the power cord 4 root ), This saves you 3 individual I/O mouth (PA15/JTDI、PB3/JTDO、PB4/JNTRST) For other purposes , And it can save some board space ( just 4 Just take a bite ).
 
    Now let me say something SWD Some steps of two-wire simulation 、 Precautions and problems needing attention .
 
    The interface is connected as follows : take JLINK Of 1、7、9、20 And their own development boards JTAG Of VCC、JTMS、JTCK、GND Connect with DuPont line !


 
    Next, let's tell you how to use SWD Set up :
 
Open the project OPTION Set up :
 
SWD Set up .jpg
 
         In the setting, it is set to... According to the above figure SWD Pattern , You can set the speed according to your actual needs , If your board power supply system is not particularly stable , If the ripple is large or the simulation line is long, it can be set to 500K perhaps 1M, If the environment is good, of course you can choose 10M , Of course the speed will fly .
 
    Remember not to ignore the one at the bottom left USB still TCP Pattern , Of course we are USB Pattern , Because sometimes the default is TCP Pattern , At this time, if we ignore this setting, we will simulate that the connection is often unavailable .
 
Press SW Way to debug , Actually, it is necessary to connect 1,7,9,15,20 foot , Some materials say it is necessary 6 A foot ( The first 13 foot SWO It also needs to be connected ) It is not right ,SWO There is no need to connect .
 
my Jilnk and Development board Wiring diagram :
 
Jtag-Jlink- Connection method .jpg
 
  • The white line : 3.3v      
  • Black line : GND      
  • Gray line :SWIO
  • Purple line :SWCLK
         About whether to connect Reset Pin problem I didn't connect it during the test   It can be downloaded and debugged normally   And the download speed is set to 10Mhz   Still no problem   The speed is really much faster ..
 

原网站

版权声明
本文为[richardgann]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202280548347013.html