您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > STM8-SWIM通信协议和调试模块
SmallmountSTM8应用笔记.1STM8SWIM通信协议和调试模块STM8的SWIM通信协议(communicationprotocol)和调试模块介绍本手册为需要建立STM8微控制器系列的编程,测试或调试工具的开发者而写。它解释了STM8内核的调试结构。STM8的调试系统包括以下两个模块:DM:调试模块;SWIM:单总线接口模块。相关文档(Relateddocumentation):HowtoprogramSTM8SandSTM8AFlashprogrammemoryanddataEEPROM(PM0051)(STM8Aversionisnotpublishedyet)HowtoprogramSTM8LFlashprogrammemoryanddataEEPROM(PM0054)专业术语:DM:DebugModeSWIM:SerialWireInterfaceModuleWFI:WaitForInterruptWFE:WaitForEventSmallmountSTM8应用笔记.2STM8SWIM通信协议和调试模块目录1.调试系统概述...........................................................................................................12.通信层.......................................................................................................................23.单总线接口模块(SWIM)....................................................................................33.1操作模式...................................................................................................................33.2SWIM入口序列.......................................................................................................33.3位格式.......................................................................................................................53.4SWIM通信协议.......................................................................................................63.5SWIM命令...............................................................................................................73.6SWIM通信复位.......................................................................................................83.7CPU寄存器访问......................................................................................................83.8在停止模式下的SWIM通信..................................................................................93.9物理层.......................................................................................................................93.10STM8的SWIM寄存器...........................................................................................94.调试模块(DM)..................................................................................................124.1介绍.........................................................................................................................124.2主要特点.................................................................................................................124.3调试.........................................................................................................................124.4断点解码表.............................................................................................................144.5软断点模式.............................................................................................................144.6时序描述.................................................................................................................144.7中止(abort)..............................................................................................................154.8数据断点.................................................................................................................154.9指令断点(Instructionbreakpoint)......................................................................154.10单步模式.................................................................................................................164.11应用笔记.................................................................................................................164.12DM寄存器.............................................................................................................165.常见问题解答.........................................................................................................175.1时序相关.................................................................................................................17SmallmountSTM8应用笔记.1STM8SWIM通信协议和调试模块1.调试系统概述STM8的调试系统接口允许一个调试或编程工具,通过一根基于开漏接口的单总线双向(bidirectional)通信线连接到MCU。它提供了非抢占式(non-intrusive)读写方式去访问RAM和外设,在程序执行期间(duringprogramexecution)。方框图(Theblockdiagram)如所示。调试模块使用设备中的两个内部时钟源,LSI低速内部时钟(通常范围为20KHz-200KHz,视产品而定)和HSI高速内部时钟(通常范围为10MHz-25MHz,视产品而定)。必要时,时钟会自动启动。SmallmountSTM8应用笔记.2STM8SWIM通信协议和调试模块2.通信层SWIM是一个基于异步(asynchronous),强灌电流(highsink)(8mA),开漏,双向通信(bidirectionalcommunication)的单总线接口。当CPU正在运行,出于调试目的,SWIM允许非抢占式(non-intrusive)读写访问,去执行on-the-flay到RAM和外设寄存器。此外(Inaddition),当CPU停止(stalled),SWIM允许读写访问,去执行MCU存储空间的其它部分(数据EEPROM和程序存储器)。CPU寄存器(A,X,Y,CC,SP)也可以被访问。这些寄存器被映射在存储器中,而且可以以相同的方式去访问。仅仅当SWIM_DM位置一时,寄存器,外设和存储器才被访问。当系统处于停止(HALT),WFI或者读保护模式,SWIM_CSR寄存器的NO_ACCESS标志将置一。在这种情况下,禁止(itisforbiddento)执行任何的访问,这时因为部分设备可能没有时钟驱动,读访问返回无用的数据(garbage),或者写访问不成功。SWIM可以执行MCU软件复位操作SWIM引脚可以作为标准IO口用于MCU的目标应用,如果你也想将他用于调试,IO口功能将会有一些限制(somerestrictions)。最安全的方式是在PCB设计时提供选择项(astrapoption)。SmallmountSTM8应用笔记.3STM8SWIM通信协议和调试模块3.单总线接口模块(SWIM)3.1操作模式上电复位后,SWIM复位,并且进入它的OFF模式。1.OFF:在此模式下,SWIM引脚一定不能在应用中用作I/O口。等待SWIM入口序列(entrysequence)或者应用软件打开I/O模式。2.I/O:软件应用程序设置内核配置寄存器(CFG_GCR)的SWIM禁能位(SWD)(SWIMdisable),可以进入此状态。在此状态下,用户应用程序可以使用SWIM引脚作为标准I/O引脚,仅有的缺陷是无法使用该引脚的内置(bulit-in)调试功能。一旦复位(Incaseofareset),SWI
本文标题:STM8-SWIM通信协议和调试模块
链接地址:https://www.777doc.com/doc-5691035 .html