quartz/content/computer_sci/hardware/MCU/different_programming_interfaces.md
2024-03-02 14:59:55 +08:00

4.0 KiB
Raw Blame History

title tags date
Different Programming Interfaces
hardware
2024-02-28

What is programming interfaces in MCU

programming interface is a device that allows a programmer to connect to a microcontroller (MCU) and program it. The programming interface is used to load the program into the MCUs memory and debug it.

Different types of programming interfaces in MCU

Chipmakers have different names for programming interfaces that all basically do the same thing:

  • ISP - programming interface for Atmel (now Microchip) AVRs. SPI-like (MISO, MOSI, SCK, reset). It can be used for flash programming and debugging.
  • PDI - newer programming interface for Atmel AVRs (eg. Xmega). Uses two wires (data and clock). Can do the same as ISP.
  • DebugWire - yet another interface from Atmel (this one uses only a single wire)
  • ICSP - programming interface for Microchip PIC line of MCUs
  • SWD - Serial Wire Debug - programming interface for MCUs with ARM Cortex-M cores (uses two wires - data and clock)
  • JTAG - very generic term, SPI-like interface used for boundary scan, can also be used for programming/debugging MCUs (almost every vendor has its own protocol, so Cortex-M JTAG is not the same as AVR JTAG or Blackfin JTAG)
  • Spy-Bi-Wire - yet another two wire programming interface, this one is for TI's MSP430 MCUs

SWD 和 JTAG的区别

目前在使用的st link可以使用SWD和JTAG这两种debugger去调试stm32所以这两种方式的区别令人比较在意

  • JTAGJoint Test Action Group联合测试行动小组是一种国际标准测试协议主要用于芯片内部测试。现在多数的高级器件都支持JTAG协议如ARM、DSP、FPGA器件等。JTAG调试接口必须使用VCC、GND电源信号以及TMS、TCK、TDI、TDO四根调试信号可选TRST、RESET复位信号和RTCK同步时钟信号。

    • TMS(Test Mode Select)模式选择TMS用来设置JTAG接口处于某种特定的测试模式
    • TCK(Test Clock):时钟输入;
    • TDI(Test Data Input)数据输入数据通过TDI引脚输入JTAG接口
    • TDO(Test Data Output)数据输出数据通过TDO引脚从JTAG接口输出
  • 串行调试Serial Wire Debug是一种和JTAG不同的调试模式使用的调试协议也不一样所以最直接的体现在调试接口上与JTAG的20个引脚相比SWD只需要4个或者5个引脚结构简单但是使用范围没有JTAG广泛主流调试器上也是后来才加的SWD调试模式。

    • SWDIO串行数据输入输出作为仿真信号的双向数据信号线建议上拉
    • SWCLK串行时钟输入作为仿真信号的时钟信号线建议下拉
    • SWO串行数据输出引脚CPU调试接口可通过SWO引脚输出一些调试信息。该引脚是可选的
    • RESET仿真器输出至目标CPU的系统复位信号该引脚也为可选
  • SWD模式比JTAG在高速模式下面更加可靠。在大数据量的情况下面JTAG下载程序会失败但是SWD发生的几率会小很多。基本使用JTAG仿真模式的情况下是可以直接使用SWD模式的只要你的仿真器支持。

  • 在GPIO刚好缺一个的时候可以使用SWD仿真这种模式支持更少的引脚。

  • 同时JTAG调试版本不同的情况下

    • JTAGV6 需要的硬件接口为: GND, RST, SWDIO, SWDCLK
    • JTAGV7 需要的硬件接口为: GND, RST, SWDIO, SWDCLK相对V6 其速度有了明显的提高,速度是 JTAGV6 的 6 倍。
    • JTAGV8 需要的硬件接口为: VCC, GND, RST, SWDIO, SWDCLK速度可以到 10M。

Reference

JTAG, SWD, EDBG, ICSP, ISP terms - Electrical Engineering Stack Exchange

jtag和swd的区别_jtag和swd区别_耶稣赞我萌的博客-CSDN博客

STM32的JTAG和SWD模式_学术马的博客-CSDN博客