MSP430比较器A 用户指南中文版
- 格式:pdf
- 大小:439.96 KB
- 文档页数:20
MSP430混合信号微控制器数据手册产品特性●低电压范围:2.5V~5.5V 超低功耗●超低功耗——活动模式:330μA at 1MHz, 3V——待机模式:0.8μA——掉电模式(RAM数据保持):0.1μA ●从待机模式唤醒响应时间不超过6μs ●16位精简指令系统,指令周期200ns ●基本时钟模块配置基本时钟模块配置——多种内部电阻——多种内部电阻——单个外部电阻——单个外部电阻——32kHz晶振晶振——高频晶体——高频晶体——谐振器——谐振器——外部时钟源——外部时钟源●带有三个捕获/比较寄存器的16位定时器(Timer_A)串行在线可编程●串行在线可编程●采用保险熔丝的程序代码保护措施采用保险熔丝的程序代码保护措施该系列产品包括●该系列产品包括——MSP430C111:2K字节ROM,128字节RAM ——MSP430C112:4K字节ROM,256字节RAM ——MSP430P112:4K字节OTP,256字节RAM 原型●EPROM原型——PMS430E112:4KB EPROM, 256B RAM ●20引脚塑料小外形宽体(SOWB)封装,20引脚陶瓷双列直插式(CDIP)封装(仅EPROM)●如需完整的模块说明,请查阅MSP430x1xx系列用户指南(文献编号:SLAU049 产品说明TI公司的MSP43O系列超低功耗微控制器由一些基本功能模块按照不同的应用目标组合而成。
在便携式测量应用中,这种优化的体系结构结合五种低功耗模式可以达到延长电池寿命的目的。
以达到延长电池寿命的目的。
MSP430MSP430系列的CPU 采用16位精简指令系统,集成有16位寄存器和常数发生器,发挥了最高的代码效率。
它采用数字控制振荡器(DCO DCO)),使得从低功耗模式到唤醒模式的转换时间小于6μs.MSP430x11x 系列是一种超低功耗的混合信号微控制器,系列是一种超低功耗的混合信号微控制器,它拥有一个内置的它拥有一个内置的16位计数器和14个I/0引脚。
文章转载自网络-----------------感谢原作者的辛勤奉献MSP430的定时器中有比较捕获比较模式:这是定时器的默认模式,当在比较模式下的时候,与捕获模式相关的硬件停止工作,如果这个时候开启定时器中断,然后设置定时器终值(将终值写入TACCRx),开启定时器,当TAR的值增到TACCRx的时候,中断标志位CCIFGx 置一,同时产生中断。
若中断允许未开启则只将中断标志位CCIFGx置一。
例子:比较模式就像51单片机一样,要能够软件设置定时间隔来产生中断处理一些事情,如键盘扫描,也可以结合信号输出产生时序脉冲发生器,PWM信号发生器。
如:不断装载TACCRx,启动定时器,TAR和TACCRx比较产生中断处理。
捕获模式:利用外部信号的上升沿、下降沿或上升下降沿触发来测量外部或内部事件,也可以由软件停止。
捕获源可以由CCISx选择CCIxA,CCIxB,GND,VCC。
完成捕获后相应的捕获标志位CCIFGx置一捕获模式的应用:利用捕获源的来触发捕获TAR的值,并将每次捕获的值都保存到TACCRx 中,可以随时读取TACCRx的值,TACCRx是个16位的寄存器,捕获模式用于事件的精确定位。
如测量时间、频率、速度等例子:利用两次捕获的值来测量脉冲的宽度。
或捕获选择任意沿,CCISx=”11“(输入选择VCC),这样即当VCC与GND发生切换时产生捕获条件结合利用:异步通讯同时应用比较模式和捕获模式来实现UART异步通信。
即利用定时器的比较模式来模拟通讯时序的波特率来发送数据,同时采用捕获模式来接收数据,并及时转换比较模式来选定调整通信的接受波特率,达到几首一个字节的目的----------------------------------------利用MSP430单片机定时器A和捕获/比较功能模块结合使用,实现脉冲宽度的测量。
本例程用到了定时器A的CCI1A端口(例如MSP430F14X的P1.2引脚)作捕获外部输入的脉冲电平跳变,同时结合简单的软件算法就能实现脉冲宽度的测量。
MSP430单片机比较器A模块比较器A模块以下图可以看出比较器A的结构大概可以分4部分构成,分别为模拟输入,比较器A核心,低通虑波器,基准电压部分和中断部分组成。
首先,整个比较器A的工作必需由CAON位置为1时才能工作的,此位属CACTL1控制寄存器。
单片机上电时此位是为0的,也就是说比较器是不工作的。
以下大概讲述几个部分电路的功能和一些相关信息。
模拟输入电路:外部模拟引脚信号CA0,CA1(正负端)可以分别由P2CA0,P2CA1位控制开或关。
经过软件的设置可以分别与内部的几个基准电压进行比较(0.5VCC,0.25VCC,三极管门值电压)或外部其中的电压进行比较。
应用的硬件比较可以分为以下三种组合:两个外部引脚输入信号进行比较其中一个外部引脚信号与内部的0.5VCC或0.25VCC比较其中一个外部引脚信号与内部基准电压比较参考电压发生器参考电压电路是可以由CARSEL,CARERF0,CARERF1位来控制电压的产生。
通过软件设置可以选择几种电压输出到比较器的输入中作为比较,当然此参考电压也可以通过单片机的引脚往外部提供参考电压之用。
比较器A核心比较器CAON位控制开关,CAEX位控制位控制方向。
低通虑波器低通虑波器只需一个CAF位来控制此虑波器的功能开与关。
此虑波器功能是用于消除比较器输出信号的毛剌,以保证信号的质量和中断请求的可靠性。
中断请求比较器A模块是具有中断功能的,如比较器功能CAIE中断允许开了,在CAIF信号产生时将生产中断(当然GIE要为1时)。
比较器A模块是具有中断独立向量的,是一个单独的中断,CUP接受请求后会硬件自动清除中断标志位CAIFG。
比较器模块相关寄存器说明CACTL1 比较器控制寄存器1CAEX:控制内部比较器A的输入信号和输出信号的方向CARSEL:控制内部参考电压加到比较器A的正输入端还是负输入端由结构图可以看出,CAEX,CARSEL在不同设置时,比较器A输入端的所加的参考电压是有不同的.请参考以下列表:-----------------------------------CARSEL CAEX参考电压接入端0 0 内部参考源加到比较器的正端0 1 内部参考源加到比较器的负端1 0 内部参考源加到比较器的负端 1 1 内部参考源加到比较器的正端CAREF1, CAREF0选择参考源:0 使用外部参考1 选择0.25VCC为参考电压2 选择0.5VCC为参考电压3 选择二极管电压为参考电压,须参见具体IC的资料CAON:控制比较器A的打开与关闭0 关闭比较器工作1 打开比较器工作CAIES:中断边沿触发模式选择0 上升沿使中断标志CAIFG置位1 下降沿使中断标志CAIFG置位CAIE:比较器中断允许0 禁止中断1 允许中断CAIFG: 比较器中断标志0 没有中断请求1 有中断请求标志信号CACTL2 比较器控制寄存器2P2CA1:控制输入端CA10 外部引脚信号不与比较器A连接1 外部引脚信号与比较器A连接P2CA0:控制输入端CA00 外部引脚信号不与比较器A连接1 外部引脚信号与比较器A连接CAF: 选择比较器输出端是否经过RC低通滤波器0 开通RC低通滤波器1 直通信号CAOUT:比较器A输出的信号0 CA0小于CA11 CA0大于CA1CAPD 端口禁止寄存器比较器A模块的输入输出与IO口共用引脚,可以控制IO端口输入缓冲器的通断开关.CAPD控制位初始化为0,则端口输入缓冲器有效.当相应位为1时,端口输入缓冲器无效。
第一讲软件使用实验板使用msp430g2553的芯片,需要使用IAR FOR MSP430 5.5以上版本一、软件安装打开EW430-EV-web-5502.exe开始安装连续点击next这里点击上面的圆点,再点next这时需要填写name,company,license。
name,company可以随意填写,license使用破解器生成。
打开文件IAR kegen PartA.exe。
从product菜单中选择msp430 v5.50,点击generate如图,得到了license number 和license key,将license number输入刚才打开的安装文件的license栏,点next接下来,在license key中输入刚才破解文件生成的license key安装选择complete,接下来,选好安装路径,就可以一直下一步直到安装完成了。
二、创建工程打开软件,看到此窗口:首先,我们新建一个工程我们使用C语言对单片机进行编程,因此选择C-main,点击ok,并保存三、配置软件建立工程以后,我们要选择芯片类型,即我们使用的msp430g2553进入option选项更改Device为g2553,并点击ok四、编译运行这时,工程设置已经完成,可以对程序进行编译仿真。
这两个按钮分别是compile和make单击make,并保存编译完成,即可开始仿真在线仿真分为是否下载两种,绿色箭头为下载最新程序后运行,空白箭头为不下载直接运行为了保证程序是最新修改,我们点击绿色箭头,即进入仿真阶段程序从main开始运行,箭头指向的绿色语句为将要运行的语句,运行结束后自动复位。
此时出现的仿真控制栏,可控制仿真的运行。
一般来说,如果不需要单步调试,点击全速运行即可。
若要结束,则点击X。
以上仿真,是基于编译器模拟的仿真,若要接上板子在线仿真,则需要做其他设置。
五、在线调试仍然是打开option选项,选择debuggerdriver中的simulator改为fet debugger此时,点击下载运行若没有连接好实验板,则会报错连接好实验板后,若驱动已经装好(若无驱动,从iar安装目录中IAR Systems\Embedded Workbench 6.4 Evaluation\430\drivers中查找安装驱动),即可看到下载成功。
T EXAS I NSTRUMENTSMPS430系列混合信号微控制器结构及模块用户指南目录1MSP430系列1.1特性与功能1.2系统关键性能1.3MSP430系列的各型号2结构概述2.1CPU2.2代码存储器2.3数据存储器(RAM)2.4运行控制2.5外围模块2.6振荡器、倍频器和时钟发生器3系统复位、中断和运行模式3.1系统复位和初始化3.2中断系统结构3.3中断处理3.3.1SFR中的中断控制位3.3.2外部中断3.4运行模式3.5低功耗模式3.5.1 低功耗模式0与模式1,LPM0和LPM1 3.5.2 低功耗模式2与模式3,LPM2和LPM3 3.5.3 低功耗模式4,LPM43.6 低功耗应用要点4 存储器组织4.1 存储器中的数据4.2 片内ROM组织4.2.1 ROM表的处理4.2.2 计算分支跳转和子程序调用4.3 RAM与外围模块组织4.3.1 RAM4.3.2 外围模块—地址定位4.3.3 外围模块--SFR5 16位CPU5.1 CPU寄存器5.1.1 程序计数器PC5.1.2 系统堆栈指针SP5.1.3 状态寄存器SR5.1.4 常数发生寄存器CG1与CG25.2 寻址模式5.2.1 寄存器模式5.2.2 变址模式5.2.3 符号模式5.2.4 绝对模式5.2.5 间接模式5.2.6 间接增量模式5.2.7 立即模式5.2.8 指令的时钟周期与长度5.3 指令组概述5.3.1 双操作数指令5.3.2 单操作数指令5.3.3 条件跳转5.3.4 模拟指令的短格式5.3.5 其它指令5.4 指令分布6 硬件乘法器6.1 硬件乘法器的操作6.2 硬件乘法器的寄存器6.3 硬件乘法器的SFR位6.4 硬件乘法器的软件限制6.4.1 硬件乘法器软件限制--寻址模式6.4.2 硬件乘法器软件限制--中断程序7 振荡器与系统时钟发生器7.1 晶体振荡器7.2 处理机时钟发生器7.3 系统时钟运行模式7.4 系统时钟控制寄存器7.4.1 模块寄存器7.4.2 与系统时钟发生器相关的SFR位7.5 DCO典型特性8 数字I/O配置8.1 通用端口P08.1.1 P0控制寄存器8.1.2 P0原理图8.1.3 P0中断控制功能8.2 通用端口P1、P28.2.1 P1、P2控制寄存器8.2.2 P1、P2原理图8.2.3 P1、P2中断控制功能8.3 通用端口P3、P48.3.1 P3、P4控制寄存器8.3.2 P3、P4原理图8.4 LCD端口8.5 LCD端口--定时器/端口比较器9 通用定时器/端口模块9.1 定时器/端口模块操作9.1.1 定时器/端口计数器TPCNT1,8位操作9.1.2 定时器/端口计数器TPCNT2,8位操作9.1.3 定时器/端口计数器,16位操作9.2 定时器/端口寄存器9.3 定时器/端口SFR位9.4 定时器/端口在A/D中的应用9.4.1 R/D转换原理9.4.2 分辨率高于8位的转换10 定时器10.1 Basic Timer110.1.1 BasicTimer1寄存器10.1.2 SFR位10.1.3 BasicTimer1操作10.1.4 BasicTimer1操作:LCD时钟信号f LCD 10.2 8位间隔(Interval)定时器/计数器10.2.1 8位定时器/计数器的操作10.2.2 8位定时器/计数器的寄存器10.2.3 与8位定时器/计数器有关的SFR 10.2.4 8位定时器/计数器在UART中的应用10.3 看门狗定时器10.3.1 看门狗定时器寄存器10.3.2 看门狗定时器中断控制功能10.3.3 看门狗定时器操作10.4 8位PWM定时器10.4.1 操作10.4.2 PWM寄存器11 Timer_A11.1 Timer_A的操作11.1.1 定时器操作11.1.2 捕获模式11.1.3 比较器模式11.1.4 输出单元11.2 Timer_A的寄存器11.2.1 Timer_A控制寄存器TACTL11.2.2 捕获/比较控制寄存器CCTL11.2.3 Timer_A中断向量寄存器11.3 Timer_A的应用11.3.1 Timer_A增计数模式应用11.3.2 Timer_A连续模式应用11.3.3 Timer_A增/减计数模式应用11.3.4 Timer_A软件捕获应用11.3.5 Timer_A处理异步串行通信协议11.4 Timer_A的特殊情况11.4.1 CCR0用作周期寄存器11.4.2 定时器寄存器的启/停11.4.3 输出单元Unit012 USART外围接口,UART模式12.1 异步操作12.1.1 异步帧格式12.1.2 异步通信的波特率发生器12.1.3 异步通信格式12.1.4 线路空闲多处理机模式12.1.5 地址位格式12.2 中断与控制功能12.2.1 USART接收允许12.2.2 USART发送允许12.2.3 USART接收中断操作12.2.4 USART发送中断操作12.3 控制与状态寄存器12.3.1 USART控制寄存器UCTL12.3.2 发送控制寄存器UTCTL12.3.3 接收控制寄存器URCTL12.3.4 波特率选择和调制控制寄存器12.3.5 USART接收数据缓存URXBUF12.3.6 USART发送数据缓存UTXBUF12.4 UART模式,低功耗模式应用特性12.4.1 由UART帧启动接收操作12.4.2 UART模式波特率与时钟频率12.4.3 节约MSP430资源的多处理机模式12.5 波特率的计算13 USART外围接口,SPI模式13.1 USART的同步操作13.1.1 SPI模式中的主模式,MM=1、SYNC=1 13.1.2 SPI模式中的从模式,MM=0、SYNC=1 13.2 中断与控制功能13.2.1 USART接收允许13.2.2 USART发送允许13.2.3 USART接收中断操作13.2.4 USART发送中断操作13.3 控制与状态寄存器13.3.1 USART控制寄存器13.3.2 发送控制寄存器UTCTL13.3.3 接收控制寄存器URCTL13.3.4 波特率选择和调制控制寄存器13.3.5 USART接收数据缓存URXBUF 13.3.6 USART发送数据缓存UTXBUF14 液晶显示驱动14.1 LCD驱动基本原理14.2 LCD控制器/驱动器14.2.1 LCD控制器/驱动器功能14.2.2 LCD控制及模式寄存器14.2.3 LCD显示存储器14.2.4 LCD操作软件例程14.3 LCD端口功能14.4 LCD与端口模式混合应用实例15 A/D转换器15.1 概述15.2 A/D转换操作15.2.1 A/D转换15.2.2 A/D中断15.2.3 A/D量程15.2.4 A/D电流源15.2.5 A/D输入端与多路切换15.2.6 A/D接地与降噪15.2.7 A/D输入与输出引脚15.3 A/D控制寄存器16 其它模块16.1 晶体振荡器16.2 上电电路16.3 晶振缓冲输出附录A 外围模块分布附录B 指令组说明附录C EPROM编程本书用途及表述约定MSP430用户指南以方便工程师及程序员使用的方式提供软件和硬件资料,以帮助开发应用MSP430系列的产品。
用于MSP430™的IAR嵌入式工作平台版本3+用户指南Literature Number:ZHCU026XJune2004–Revised November2011内容Preface (5)1现在就开始! (7)1.1软件安装 (8)1.2LED闪烁 (8)1.3光盘和网络上重要的MSP430文档 (9)2开发流程 (10)2.1概述 (11)2.2使用KickStart (11)2.2.1项目设置 (12)2.2.2用于MSP430L092/MSP430C092的附件项目设置 (13)2.2.3从零开始创建一个项目 (15)2.2.4用于LPMx.5调试的附加项目设置 (16)2.2.5MSP430器件的密码保护 (17)2.2.6使用一个现有的IAR V1.x/V2.x/V3.x项目 (18)2.2.7堆栈管理和.xcl文件 (18)2.2.8如何生成德州仪器(TI).TXT(和其它格式)文件 (18)2.2.9示例程序概述 (18)2.3使用C-SPY (18)2.3.1断点类型 (19)2.3.2使用断点 (20)2.3.3使用单步执行 (21)2.3.4使用观察窗口 (21)A常见问题和解答 (23)A.1硬件 (24)A.2程序开发(汇编语言、C语言编译器、连接器) (24)A.3调试中(C-SPY) (26)B FET专用菜单 (30)B.1菜单 (31)B.1.1Emulator→Device Information (31)B.1.2Emulator→Release JTAG on Go (31)B.1.3Emulator→Resynchronize JTAG (31)B.1.4Emulator→Init New Device (31)B.1.5Emulator→Secure-Blow JTAG Fuse (31)B.1.6Emulator→Breakpoint Usage (31)B.1.7Emulator→Advanced→Clock Control (31)B.1.8Emulator→Advanced→Emulation Mode (31)B.1.9Emulator→Advanced→Memory Dump (32)B.1.10Emulator→Advanced→Breakpoint Combiner (32)B.1.11Emulator→State Storage Control (32)B.1.12Emulator→State Storage Window (32)B.1.13Emulator→Sequencer Control (32)B.1.14Emulator→"Power on"Reset (32)B.1.15Emulator→GIE on/off (32)B.1.16Emulator→Leave Target Running (32)B.1.17Emulator→Force Single Stepping (32)文档修订历史记录 (33)图片列表1-1.激活项目 (8)1-2.在Workspace Overview中激活项目 (9)2-1.L092模式 (13)2-2.C092仿真模式 (13)2-3.C092密码 (14)2-4.启用LPMx.5 (16)2-5.LPMx.5通知 (17)2-6.JTAG密码 (17)图表列表2-1.器件架构、断点和其它仿真特性 (19)4图片列表ZHCU026X–June2004–Revised November2011PrefaceZHCU026X–June2004–Revised November2011请先阅读关于本手册这本手册说明了IAR嵌入式工作平台(EW430)(带有MSP430超低功耗微控制器)™的使用方法。
IAR FOR 430 入门教程主要内容:一.IAR FOR 430 简介二.IAR软件的安装及破解三.软件的设置与调试SRa一.IAR FOR 430 简介IAR Systems是全球领先的嵌入式系统开发工具和服务的供应商。
公司成立于1983年,迄今已有27年,提供的产品和服务涉及到嵌入式系统的设计、开发和测试的每一个阶段,包括:带有C/C++编译器和调试器的集成开发环境(IDE)、实时操作系统和中间件、开发套件、硬件仿真器以及状态机建模工具。
国内普及的MSP430开发软件种内不多,主要有IAR公司的Embedded Workbench for MSP430(简称为EW430)和AQ430。
目前IAR的用户居多。
IAR EW430软件提供了工程管理,程序编辑,代码下载,调试等所有功能。
并且软件界面和操作方法与IAR EW for ARM等开发软件一致。
因此,学会了IAR EW430,就可以很顺利地过渡到另一种新处理器的开发工作。
现在IAR的最新版本为V5.10版,不过本文主要是以V4.11版讲解。
各个版本之间差异不大。
掌握了V4.11,别的版本也能很快上手。
二.IAR软件的安装及破解(1)软件的下载及破解IAR EW430在google or百度上很容易找到下载连接,也可以在IAR官网上下载,不过一定要将与版本相配套的注册机一并下载。
(2)软件的安装1.运行ew430-ev-cd-411b.exe2. 点击Next3点击AcceptName, Company 自己可以随意填License(序列号)就得用到注册机了运行注册机(iarkg.exe),可以看到首先在product中选EmbededWorkbenchForMSP430 v4.11B然后点击Generate生成License number和License Key 将License number输到Licinse#中4.点击Next将注册机中的LicenseKey粘贴进去5点击Next,出现修改安装路径,这个随意,按个人喜好了6修改好后,点击Next选择Full,继续Next7 之后基本不用设置什么了,一路Next就OK了8出现点击Finish大功告成!注意:1.License number和License Key必须配套。
MSP430AFE2x3MSP430AFE2x2MSP430AFE2x1 ZHCS136A–NOVEMBER2010–REVISED MARCH2011混合信号微控制器特性•低电源电压范围:1.8V至3.6V•多达3个具有差分可编程增益放大器(PGA)输入的24位三角积分模数(A/D)转换器•超低功耗•具有3个捕获/比较寄存器的16位Timer_A –激活模式:220μA(在1MHz频率和2.2V电压条件下)•串行通信接口(USART),可用软件来选择异步UART或同步SPI–待机模式:0.5μA•16位硬件乘法器–关闭模式(RAM保持):0.1μA•欠压检测器•5种节能模式•具有可编程电平检测功能的电源电压监控器/监视器•可在不到1μs的时间里超快速地从待机模式唤醒•串行板上编程,无需从外部进行电压编程,利用安•16位精简指令集(RISC)架构,高达12MHz系统时全熔丝实现可编程代码保护钟•片上仿真模块•基本时钟模块配置•系列成员汇总于表1。
–带有两个已校准频率的高达12MHz的内部频率•如需了解完整的模块说明,请参阅《MSP430x2xx –内部超低功耗低频(LF)振荡器系列用户指南》,文献编号SLAU144–高达16MHz的高频(HF)晶振–谐振器–外部数字时钟源说明德州仪器(TI)MSP430™系列超低功率微控制器包含几个器件,这些器件特有针对多种应用的不同的外设集。
这种架构与5种低功耗模式相组合,专为在便携式测量应用中延长电池使用寿命而优化。
该器件具有一个强大的16位RISC CPU,16位寄存器和有助于获得最大编码效率的常数发生器。
数字控制振荡器(DCO)可在不到1µs 的时间里完成从低功耗模式至运行模式的唤醒。
MSP430AFE2x3器件是超低功耗混合信号微控制器,集成了三个独立的24位三角积分A/D转换器、一个16位定时器、一个16位硬件乘法器、USART通信接口、安全装置定时器和11个I/O引脚。
DM430-A操作⼿册V1.0DM430-AUSB型MSP430F149(169)单⽚机开板使⽤⼿册V3.02014年10⽉使⽤必读DM430-A是由欣世纪电⼦科技出品的超⾼性价⽐USB型MSP430单⽚机开发板,具有应⽤丰富使⽤简单的特点,⽤户在使⽤前请务必认真阅读本⼿册,并进⾏测试,切勿在没有仔细浏览⼿册之前对开发板进⾏相关操作,否则由此导致的⼀切问题由⽤户⾃⾏承担责任。
售后服务请参考欣世纪电⼦科技官⽅⽹站相关介绍。
技术⽀持技术⽀持由DM430-A型单⽚机开发板开发商欣世纪电⼦科技全权负责。
官⽅⽹站:/doc/4d2a7cf6b9d528ea81c779d1.html公司地址:浙江宁波江北区环城北路东段134号科技创业中⼼C504室联系电话:0574-********技术⽀持邮箱:support@/doc/4d2a7cf6b9d528ea81c779d1.html产品询问邮箱:product@/doc/4d2a7cf6b9d528ea81c779d1.html技术服务QQ:6241569691072969215声明该操作⼿册由V2.0升级到V3.0,主要对板载资源接⼝更新部分做了扩充说明,其他未变动部分均予以原⽂保留,因此部分图⽚引⽤原V2.0图⽚,敬请注意!⽬录⽬录 (2)第⼀章概述 (6)第⼆章开发板使⽤⼊门 (7)2.1DM430-A开发板特点 (7)2.2开发板资源框图 (8)2.3开发板可以完成的实验 (9)2.4开发板提供的测试例程 (9)2.5软件平台的安装与使⽤ (9)2.5.1软件的下载 (10)2.5.2软件的安装 (10)2.5.3第⼀个⼯作窗与⼯程的建⽴与编译 (12)2.6USB型BSL下载器硬件连接配置及使⽤ (20)2.6.1BSL下载器硬件连接及驱动 (20)2.6.2使⽤BSL进⾏程序下载 (22)1、使⽤SF_BSL430软件下程序下载(64位系统不推荐) (22)2、MSPFET软件下载设置(推荐使⽤) (24)2.7开发板的测试 (26)第三章MSP430单⽚机概述 (28)3.1MSP430系列单⽚机的特点 (28)3.1.2强⼤的处理能⼒ (28)3.1.3⾼性能模拟技术及丰富的⽚上外围模块 (29)3.1.4系统⼯作稳定 (29)3.1.5⽅便⾼效的开发环境 (29)3.2MSP430系列单⽚机的发展和应⽤ (29)3.3MSP430系封装图及命名规则 (30)第四章开发板物理资源模块详解 (32)4.1DM430-A开发板电源系统 (32)4.28位LED发光⼆极管 (33)4.3蜂鸣器硬件连接 (34)4.4共阴型⼋位数码管硬件驱动及连接 (35)4.5四位独⽴键盘(四位中断键盘) (37)4.64x4矩阵键盘 (38)4.7温度传感器DS18B20 (39)4.8双路12位ADC输⼊ (41)4.910位串⾏电压型DAC (42)4.10EEPROM硬件连接 (44)4.11⼀体化红外接收头1838 (45)4.131602液晶接⼝硬件连接 (48)4.14带字库图形12864液晶接⼝ (49)4.15串⼝RS232及RS485接⼝资源介绍 (51)4.16NRF24L01⽆线射频接⼝ (52)4.17实时时钟芯⽚DS1302控制与读写实验 (53)4.18PWM调制波形输出显⽰ (54)4.19PS2键盘接⼝ (55)4.20TFT彩⾊液晶接⼝ (56)4.20.11.8⼨TFT真彩屏接⼝(8位并⼝) (57)4.20.22.8⼨TFT触摸屏接⼝ (59)4.21MMC/SD卡扩展接⼝ (61)4.22JTAG仿真接⼝ (63)4.23扩展IO接⼝ (64)第五章注意事项及安装⽰范 (65)5.1使⽤仿真器时注意事项 (65)5.2液晶安装⽅法⽰范 (65)5.2.11602液晶安装⽰范 (65)5.2.212864液晶安装⽰范 (66)5.2.31.8⼨TFT彩⾊液晶安装⽰范 (67)5.2.42.8⼨TFT彩⾊触摸屏液晶安装⽰范 (68)5.3步进电机安装⽰范 (69)5.4核⼼转接板安装⽰范 (70)5.5⽆线模块NRF24L01安装⽰范 (71)第六章测试程序 (72)附录 (73)附录15V步进电机详细参数 (73)附录2BMP图⽚⽂件格式详解 (74)结束语 (83)第⼀章概述DM430-A是由欣世纪电⼦科技(/doc/4d2a7cf6b9d528ea81c779d1.html )推出的⼀款基于MSP430F149的具有超⾼性价⽐的USB型多功能复合型MSP430单⽚机开发板,板载USB型BSL下载器,使⽤⾮常简单⽅便,该开发板板载了丰富的外围资源模块,包括8位⾼亮数码管、8位发光⼆极管、有源蜂鸣器、温度传感器、EEPROM芯⽚、DAC芯⽚、MAX232通信芯⽚、DS1302实时时钟芯⽚、MAX485芯⽚、步进电机驱动芯⽚、4X4矩阵键盘、4位独⽴键盘、4位中断键盘、红外⼀体化接收、SD卡接⼝、RS232通信模块、RS485通信模块、12864液晶接⼝、1602液晶接⼝、TFT彩屏模块接⼝、TFT触摸屏接⼝、PS2通信接⼝及⽆线射频NRF24L01接⼝,同时⽀持JTAG调试,2X7座兼容官⽅标准,可以匹配市场上的各种JTAG仿真器,板载的BSL下载器可以通过杜邦线对其他开发板进⾏程序下载,另外,板载的BSL模块可以独⽴作为USB转串⼝使⽤,解决笔记本电脑没有串⼝的问题或可以作为其他单⽚机下载器,如STC单⽚机下载器。
MSP430™Programming Via the JTAG Interface User's GuideLiterature Number:SLAU320CJuly2010–Revised October2011Contents 1Programming Via the JTAG Interface (5)1.1Introduction (5)1.2Interface and Instructions (6)1.2.1JTAG Interface Signals (6)1.2.2JTAG Access Macros (8)1.2.3Spy-Bi-Wire(SBW)Timing and Control (10)1.2.4JTAG Communication Instructions (14)1.3Memory Programming Control Sequences (20)1.3.1Start-Up (20)1.3.2General Device(CPU)Control Functions (23)1.3.3Accessing Non-Flash Memory Locations With JTAG (31)1.3.4Programming the Flash Memory(Using the Onboard Flash Controller) (35)1.3.5Erasing the Flash Memory(Using the Onboard Flash Controller) (40)1.3.6Reading From Flash Memory (44)1.3.7Verifying the Flash Memory (44)1.3.8FRAM Memory Technology (44)1.4JTAG Access Protection (45)1.4.1Burning the JTAG Fuse-Function Reference for1xx/2xx/4xx Families (45)1.4.2Programming the JTAG Lock Key-Function Reference for5xx Family (47)1.4.3Testing for a Successfully Protected Device (48)1.4.4Unlocking a Password-Protected Device (48)1.5JTAG Function Prototypes (50)1.5.1Low-Level JTAG Functions (50)1.5.2High-Level JTAG Routines (51)1.6References (56)2JTAG Programming Hardware and Software Implementation (57)2.1Implementation History (57)2.2Implementation Overview (57)2.3Software Operation (58)2.4Software Structure (59)2.5Programmer Operation (61)2.6Hardware Setup (61)2.6.1Host Controller (61)2.6.2Target Connection (62)2.6.3Host Controller/Programmer Power Supply (64)2.6.4Third Party Support (64)3Internal MSP430JTAG Implementation (65)3.1TAP Controller State Machine (65)3.2MSP430JTAG Restrictions(Non-Compliance With IEEE Std1149.1) (65)A Errata and Revision Information (67)A.1Known Issues (67)A.2Revisions and Errata from Previous Documents (67)Revision History (69)TCK TMSTDI TDO TCLKData to TDI LSB MSB1.2.2JTAG Access MacrosTo keep descriptions of the JTAG functions in the following sections simple,high-level macros have been used to describe the JTAG access.This document does not detail the basic JTAG functionality;rather,it focuses on the MSP430-specific implementation used for memory access and programming.For thepurpose of this document,it is important to show the instructions that must be loaded into the JTAGinstruction register,as well as when these instructions are required.Section1.2.2.1summarizes themacros used throughout this document and their associated functionality.See the accompanying software for more information.Table1-5.JTAG Communication MacrosMacro Name FunctionShifts an8-bit JTAG instruction into the JTAG instruction register.At the same time,the8-bit IR_SHIFT(8-bit Instruction)value is shifted out through TDO.Shifts a16-bit data word into a JTAG data register.At the same time,the16-bit value is shifted DR_SHIFT16(16-bit Data)out through TDO.Shifts a20-bit address word into the JTAG Memory Address Bus register.At the same time,the DR_SHIFT20(20-bit Address)20-bit value is shifted out through TDO.Only applicable to MSP430X architecture devices.MsDelay(time)Waits for the specified time in millisecondsSetTCLK Sets TCLK to1ClrTCLK Sets TCLK to0TDOvalue Variable containing the last value shifted out on TDO1.2.2.1Macros for4-Wire JTAG Interface1.2.2.1.1IR_SHIFT(8-bit Instruction)This macro loads a desired JTAG instruction into the JTAG instruction register(IR)of the target device.In the MSP430,this register is eight bits wide with the least significant bit(LSB)shifted in first.The dataoutput from TDO during a write to the JTAG instruction register contains the version identifier of the JTAG interface(or JTAG ID)implemented on the target device.Regardless of the8-bit instruction sent out on TDI,the return value on TDO is always the JTAG ID.Each instruction bit is captured from TDI by thetarget MSP430on the rising edge of TCK.TCLK should not change state while this macro is executed (TCLK=TDI while the TAP controller is in the Run-Test/Idle state).Figure1-2shows how to load theADDR_16BIT instruction into the JTAG IR register.See Section1.2.4for a complete list of the JTAGinterface communication instructions used to access the target device flash memory module.Figure1-2.Timing Example for IR_SHIFT(0x83)Instruction1.2.2.1.2DR_SHIFT16(16-bit Data)This macro loads a16-bit word into the JTAG data register(DR)(in the MSP430devices,a data register1.2.4JTAG Communication InstructionsSelecting a JTAG register and controlling the CPU is done by shifting in a JTAG instruction using theIR_SHIFT macro described in Section1.2.2.1.1.The following instructions that can be written to the JTAG IR are used to program the target flash memory.All instructions sent to the target MSP430via the JTAG register are transferred LSB first.Table1-6.Memory Access Instructions8-Bit Instruction ValueInstruction Name(Hex)Controlling the Memory Address Bus(MAB)IR_ADDR_16BIT0x83IR_ADDR_CAPTURE0x84Controlling the Memory Data Bus(MDB)IR_DATA_TO_ADDR0x85IR_DATA_16BIT0x41IR_DATA_QUICK0x43IR_BYPASS0xFFControlling the CPUIR_CNTRL_SIG_16BIT0x13IR_CNTRL_SIG_CAPTURE0x14IR_CNTRL_SIG_RELEASE0x15Memory Verification Via Pseudo Signature Analysis(PSA)IR_DATA_PSA0x44IR_SHIFT_OUT_PSA0x46JTAG Access Security Fuse ProgrammingIR_Prepare_Blow0x22IR_Ex_Blow0x24JTAG Mailbox SystemIR_JMB_EXCHANGE0x61NOTE:Do not write any unlisted values to the JTAG instruction register.Instruction values written tothe MSP430JTAG register other than those listed above may cause undesired devicebehavior.NOTE:When a new JTAG instruction is shifted into the JTAG instruction register,it takes effect withthe UPDATE-IR state of the TAP controller.When accessing a JTAG data register,the lastvalue written is captured with the CAPTURE-DR state,and the new value shifted in becomesvalid with the UPDATE-DR state.In other words,there is no need to go throughRun-Test/Idle state of the JTAG TAP controller to shift in instructions or data.Be aware ofthe fact that clocking TCLK is only possible in the Run-Test/Idle state.This is why theprovided software example application exclusively makes use of the JTAG macros describedin Section1.2.2,which always go through Run-Test/Idle state. Memory Programming Control Sequences 1.3.3Accessing Non-Flash Memory Locations With JTAG1.3.3.1Read AccessTo read from any memory address location(peripherals,RAM,or flash),the R/W signal must be set to READ using the JTAG control signal register(bit0set to1).The MSP430MAB must be set to the specific address to be read using the IR_ADDR_16BIT instruction while TCLK is0.To capture the corresponding value of the MSP430MDB,the IR_DATA_TO_ADDR instruction must be executed.After the next rising edge of TCLK,the data of this address is present on the MDB.The MDB can now be captured and read out via the TDO pin using a16-bit JTAG data access.When TCLK is set low again,the address of the next memory location to be read can be applied to the target MAB.Following is the flow required to read data from any memory address of a target device.Implementations for both the MSP430and MSP430X architectures are shown.•MSP430architecture,Reference function:ReadMemSet CPU to stopped state(HaltCPU)ClrTCLKIR_SHIFT("IR_CNTRL_SIG_16BIT")DR_SHIFT16(0x2409):Read MemoryIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT16("Address"):Set desired addressIR_SHIFT("IR_DATA_TO_ADDR")YesSetTCLKClrTCLKDR_SHIFT16(0x0000):Memory value shifted out on TDORead again?NoReleaseCPU should now be executed,returning the CPU to normal operation.•MSP430X architecture,Reference function:ReadMem_430XSet CPU to stopped state(HaltCPU)ClrTCLKIR_SHIFT("IR_CNTRL_SIG_16BIT")DR_SHIFT16(0x2409):Read MemoryIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT20("Address"):Set desired addressIR_SHIFT("IR_DATA_TO_ADDR")YesSetTCLKClrTCLKDR_SHIFT16(0x0000):Memory value shifted out on TDORead again?NoReleaseCPU should now be executed,returning the CPU to normal operation.•MSP430Xv2architecture,Reference function:ReadMem_430Xv2CPU must be in the Full-Emulation-State prior to the following sequence.ClrTCLKIR_SHIFT("IR_CNTRL_SIG_16BIT")DR_SHIFT16(0x2409):Read MemoryIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT20("Address"):Set desired addressIR_SHIFT("IR_DATA_TO_ADDR")YesSetTCLKClrTCLKDR_SHIFT16(0x0000):Memory value shifted out on TDOSetTCLKClrTCLKSetTCLKRead again?NoCPU is now again in Full-Emulation-State.1.3.3.2Write AccessTo write to a memory location in peripherals or RAM(but not flash),the R/W signal must be set to WRITE using the JTAG control signal register(bit0set to0).The MAB must be set to the specific address using the IR_ADDR_16BIT instruction while TCLK is low.The MDB must be set to the data value to be written using the IR_DATA_TO_ADDR instruction and a16-bit JTAG data input shift.On the next rising edge of TCLK,this data is written to the selected address set by the value on the MAB.When TCLK is asserted low,the next address and data to be written can be applied to the MAB and MDB.After completion of the write operation,it is recommended to set the R/W signal back to READ.Following is the flow for aperipheral or RAM memory address write.Implementations for both the MSP430and MSP430Xarchitectures are shown.•MSP430architecture,Reference function:WriteMemSet CPU to stopped state(HaltCPU)ClrTCLKIR_SHIFT("IR_CNTRL_SIG_16BIT")DR_SHIFT16(0x2408):Write MemoryIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT16("Address"):Set desired addressIR_SHIFT("IR_DATA_TO_ADDR")YesDR_SHIFT16("Data"):Send16-bit DataSetTCLKWrite again?NoReleaseCPU should now be executed,returning the CPU to normal operation.•Released from JTAG controlTarget device is released from JTAG control(free running)IR_SHIFT("IR_JB_EXCHANGE")DR_SHIFT16(0x0001):Send input request to JTAG mailboxDR_SHIFT16("Data"):Shift16bit word into JTAG mailboxDR_SHIFT16(0x0000)YesNoBit0of TDOword=1?YesWrite Another Flash Address?NoGet target device in Full-Emulation-State1.3.5Erasing the Flash Memory(Using the Onboard Flash Controller)1.3.5.1Function Reference for1xx/2xx/4xx FamiliesReference function:EraseFLASHThis section describes how to erase one segment of flash memory(ERASE_SGMT),how to erase the device main memory(ERASE_MAIN),and how to perform an erase of the complete flash memoryaddress range including,main and info flash segments(ERASE_MASS).This method requires the user to provide a TCLK signal at a frequency of350kHz±100kHz while the erase cycle is being executed,as is also the case when programming the flash memory.The following tables show the segment and mass erase flows,respectively,and the minimum number of TCLK cycles required by the flash controller toperform each action(FCTL2register bits0to7=0x40).1.3.5.1.1Flow to Erase a Flash Memory SegmentSwitch CPU to stopped state(HaltCPU)ClrTCLKIR_SHIFT("IR_CNTRL_SIG_16BIT")DR_SHIFT16(0x2408):Set RW to WriteIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT16(0x0128)(1):Point to FCTL1AddressIR_SHIFT("IR_DATA_TO_ADDR")DR_SHIFT16(0xA502):Enable FLASH segment eraseSetTCLKClrTCLKIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT16(0x012A)(1):Point to FCTL2AddressIR_SHIFT("IR_DATA_TO_ADDR")DR_SHIFT16(0xA540):Source is MCLK,divider by1SetTCLKClrTCLKIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT16(0x012C)(1):Point to FCTL3AddressIR_SHIFT("IR_DATA_TO_ADDR")DR_SHIFT16(0xA500)(2):Clear FCTL3Register(1)Replace with DR_SHIFT20("Address")when programming an MSP430X architecture device.(2)Substitute0xA540for'2xx devices for Info-Segment A programming. Memory Programming Control Sequences SetTCLKClrTCLKIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT16(“EraseAddr”)(1):Set Address for Erase(3)IR_SHIFT("IR_DATA_TO_ADDR"):Write Dummy Data for EraseDR_SHIFT16(0x55AA)StartSetTCLKClrTCLKIR_SHIFT("IR_CNTRL_SIG_16BIT")DR_SHIFT16(0x2409):Set RW to ReadSetTCLKRepeat4819times(4)ClrTCLKIR_SHIFT("IR_CNTRL_SIG_16BIT")DR_SHIFT16(0x2408):Set RW to WriteIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT16(0x0128)(5):Point to FCTL1AddressIR_SHIFT("IR_DATA_TO_ADDR")DR_SHIFT16(0xA500):Disable FLASH EraseSetTCLKClrTCLKIR_SHIFT("IR_ADDR_16BIT")DR_SHIFT16(0x012C)(5):Point to FCTL3AddressIR_SHIFT("IR_DATA_TO_ADDR")DR_SHIFT16(0xA500)(6):Disable FLASH Write AccessSetTCLKReleaseCPU should now be executed,returning the CPU to normal operation.(3)The EraseAddr parameter is the address pointing to the flash memory segment to be erased.(4)Correct timing required.Must meet min/max TCLK frequency requirement of350kHz±100kHz.(5)Replace with DR_SHIFT20("Address")when programming an MSP430X architecture device.(6)Substitute0xA540for'2xx devices for Info-Segment A programming.。
IAR Embedded Workbench™Version3+ for MSP430™User's GuideLiterature Number:SLAU138AFJune2004–Revised June2014Contents Preface (6)1Get Started Now! (8)1.1Software Installation (9)1.2Flashing the LED (9)1.3Important MSP430Documents on the CD-ROM and Web (10)2Development Flow (11)2.1Overview (12)2.2Using KickStart (12)2.2.1Project Settings (13)2.2.2Using Math Library for MSP430(MSPMathlib)in IAR EW4305.60.1and Newer (14)2.2.3Additional Project Settings for MSP430L092and MSP430C092 (14)2.2.4Creating a Project From Scratch (16)2.2.5Additional Project Settings for Ultra-Low-Power Mode(LPMx.5)Debugging (17)2.2.6Password Protection for MSP430Devices (18)2.2.7Using an Existing IAR V1.x,V2.x,or V3.x Project (18)2.2.8Stack Management and.xcl Files (19)2.2.9How to Generate Texas Instruments.TXT(and Other Format)Files (19)2.2.10Overview of Example Programs (19)2.3Using C-SPY (19)2.3.1Breakpoint Types (19)2.3.2Using Breakpoints (22)2.3.3Using Single Step (22)2.3.4Using Watch Windows (23)3EnergyTrace™Technology (24)3.1Introduction (24)3.2Energy Measurement (24)3.3IAR Embedded Workbench®for MSP430Integration (24)3.3.1Debugging Devices With EnergyTrace++Technology Support (24)3.3.2Debugging Devices Without EnergyTrace++Technology Support (31)3.4Measuring Low-Power Currents (34)3.5EnergyTrace Technology FAQs (35)4Memory Protection Unit(MPU)and Intellectual Property Encapsulation(IPE) (37)A Frequently Asked Questions (38)A.1Hardware (39)A.2Program Development(Assembler,C-Compiler,Linker) (39)A.3Debugging(C-SPY) (41)B FET-Specific Menus (45)B.1Menus (46)B.1.1Emulator→Device Information (46)B.1.2Emulator→Release JTAG on Go (46)B.1.3Emulator→Resynchronize JTAG (46)B.1.4Emulator→Init New Device (46)B.1.5Emulator→Secure-Blow JTAG Fuse (46)B.1.6Emulator→Breakpoint Usage (46)2Contents SLAU138AF–June2004–Revised June2014Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedB.1.7Emulator→Advanced→Clock Control (46)B.1.8Emulator→Advanced→Emulation Mode (46)B.1.9Emulator→Advanced→Memory Dump (47)B.1.10Emulator→Advanced→Breakpoint Combiner (47)B.1.11Emulator→State Storage Control (47)B.1.12Emulator→State Storage Window (47)B.1.13Emulator→Sequencer Control (47)B.1.14Emulator→"Power on"Reset (47)B.1.15Emulator→GIE on/off (47)B.1.16Emulator→Leave Target Running (47)B.1.17Emulator→Force Single Stepping (47)Revision History (48)3 SLAU138AF–June2004–Revised June2014Contents Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedList of Figures1-1.Activate Project (9)1-2.Activate Project in Workspace Overview (10)2-1.L092Mode (14)2-2.C092Emulation Mode (15)2-3.C092Password (15)2-4.Enable Ultra-Low-Power Debug Mode (17)2-5.LPMx.5Notifications (18)2-6.JTAG Password (18)3-1.Pulse Density and Current Flow (24)3-2.Debug Session With EnergyTrace++Windows (25)3-3.Debug Options (26)3-4.Emulator Pulldown Menu With EnergyTrace++-Related Functions (27)3-5.Enabling the State Log Window (27)3-6.State Log Window With EnergyTrace++Data (28)3-7.State Log Summary With EnergyTrace++Data (28)3-8.Power Log Setup Window (28)3-9.Power Log Window With EnergyTrace++Data (29)3-10.Timeline With Power Log and State Graphs Disabled (29)3-11.Timeline With EnergyTrace++Data (30)3-12.Function Profiler With EnergyTrace++Data (30)3-13.Debug Session With EnergyTrace Windows (31)3-14.Emulator Pulldown Menu With EnergyTrace-Related Functions (32)3-15.Power Log Setup Window (32)3-16.Power Log Window With EnergyTrace Data (33)3-17.Timeline With Power Log Graph Disabled (33)3-18.Timeline With EnergyTrace Data (34)3-19.LPM3Current When Executing Under Debug Control (34)3-20.Release JTAG on Go Option in Emulator Pulldown Menu (35)3-21.LPM3Current When Executing with JTAG Signals Released (35)4-1.MPU Configuration Dialog (37)4List of Figures SLAU138AF–June2004–Revised June2014Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedList of Tables2-1.Device Architecture,Breakpoints,and Other Emulation Features (20)5 SLAU138AF–June2004–Revised June2014List of Tables Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedPrefaceSLAU138AF–June2004–Revised June2014Read This FirstAbout This ManualThis manual describes the use of IAR Embedded Workbench®(EW430)with the MSP430™ultra-low-power microcontrollers.How to Use This ManualRead and follow the instructions in the Get Started Now!chapter.This chapter provides instructions on installing the software,and describes how to run the demonstration programs.After you see how quick and easy it is to use the development tools,TI recommends that you read all of this manual.This manual describes only the setup and basic operation of the software development environment,but it does not fully describe the MSP430microcontrollers or the complete development software and hardware systems.For details of these items,see the appropriate TI and IAR™documents listed in RelatedDocumentation From Texas Instruments,Important MSP430Documents on the CD-ROM and Web.This manual applies to the use with Texas Instruments'MSP-FET430UIF,MSP-FET430PIF,and eZ430 development tools series.These tools contain the most up-to-date materials available at the time of packaging.For the latestmaterials(including data sheets,user's guides,software,and application information),visit the TI MSP430 web site at /msp430or contact your local TI sales office.Information About Cautions and WarningsThis book may contain cautions and warnings.CAUTIONThis is an example of a caution statement.A caution statement describes a situation that could potentially damage yoursoftware or equipment.The information in a caution or a warning is provided for your protection.Read each caution and warning carefully.MSP430,EnergyTrace are trademarks of Texas Instruments.6Read This First SLAU138AF–June2004–Revised June2014 IAR Embedded Workbench is a registered trademark of IAR Systems AB.Submit Documentation Feedback All other trademarks are the property of their respective owners.Copyright©2004–2014,Texas Instruments Incorporated Related Documentation From Texas Instruments Related Documentation From Texas InstrumentsMSP430development tools documentationMSP430Hardware Tools User's Guide,literature number SLAU278eZ430-F2013Development Tool User's Guide,literature number SLAU176eZ430-RF2480User's Guide,literature number SWRA176eZ430-RF2500Development Tool User's Guide,literature number SLAU227eZ430-RF2500-SEH Development Tool User's Guide,literature number SLAU273eZ430-Chronos Development Tool User's Guide,literature number SLAU292MSP430device data sheetsMSP430x1xx Family User's Guide,literature number SLAU049MSP430x2xx Family User's Guide,literature number SLAU144MSP430x3xx Family User's Guide,literature number SLAU012MSP430x4xx Family User's Guide,literature number SLAU056MSP430x5xx and MSP430x6xx Family User's Guide,literature number SLAU208MSP430FR57xx Family User's Guide,literature number SLAU272MSP430FR58xx,MSP430FR59xx,MSP430FR68xx,and MSP430FR69xx Family User's Guide,literature number SLAU367CC430device data sheetsCC430Family User's Guide,literature number SLAU259If You Need AssistanceSupport for the MSP430devices and the FET development tools is provided by the Texas Instruments Product Information Center(PIC).Contact information for the PIC can be found on the TI web site at/support.The Texas Instruments E2E Community support forums for the MSP430is available to provide open interaction with peer engineers,TI engineers,and other experts.Additional device-specific information can be found on the MSP430web site.NOTE:The KickStart kit is supported by Texas Instruments.Although the KickStart kit is a product of IAR,Texas Instruments provides the support for it.Therefore,please do not request support for KickStart from IAR.Consult the extensivedocumentation provided with KickStart before requesting assistance.7 SLAU138AF–June2004–Revised June2014Read This First Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedChapter1SLAU138AF–June2004–Revised June2014Get Started Now!This chapter provides instruction on installing the software,and shows how to run the demonstration programs.Topic Page1.1Software Installation (9)1.2Flashing the LED (9)1.3Important MSP430Documents on the CD-ROM and Web (10)8Get Started Now!SLAU138AF–June2004–Revised June2014Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments Incorporated Software Installation 1.1Software InstallationFollow the instructions on the supplied READ ME FIRST document to install the IAR EmbeddedWorkbench™KickStart kit.Read the file<Installation Root>\Embedded Workbenchx.x\430\doc\readme.htm from IAR for the latest information about the Workbench.The term KickStartrefers to the function-limited version of Embedded Workbench(including C-SPY™debugger).KickStart is supplied on the CD-ROM included with each FET,and the latest version is available from the MSP430 web site.The documents mentioned in the previous paragraph(and this document)can be accessed using:Start→Programs→IAR Systems→IAR Embedded Workbench KickStart for MSP430V3.KickStart is compatible with Windows2000(SP4),Windows XP(32bit and64bit),Windows Vista(32bit and64bit),and Windows7(32bit and64bit).However,the USB FET interface works with only Windows XP(32bit and64bit),Windows Vista(32bit and64bit),and Windows7(32bit and64bit).1.2Flashing the LEDThis section demonstrates on the FET the equivalent of the C-language"Hello World!"introductoryprogram.An application that flashes the LED is developed and downloaded to the FET,and then run.1.Start the Workbench(Start→Programs→IAR Systems→IAR Embedded Workbench KickStart forMSP430V3→IAR Embedded Workbench).2.Click File→Open Workspace to open the file at:<Installation Root>\Embedded Workbench x.x\430\FET_examples\Flashing the LED.eww.The workspace window opens.3.Click on the tab at the bottom of the workspace window that corresponds to the MSP430device(MSP430xxxx)and desired language(assembler or C)to set a project active(see Figure1-1).Figure1-1.Activate Project9 SLAU138AF–June2004–Revised June2014Get Started Now! Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedImportant MSP430Documents on the CD-ROM and Web Alternatively,right click to activate a project in the Workspace Overview tab(see Figure1-2).Figure1-2.Activate Project in Workspace Overview4.Click Project→Options→FET Debugger→Setup→Connection to select the appropriate port:Texas Instruments LPT-IF for the parallel FET Interface(MSP-FET430PIF)or Texas Instruments USB-IF for the USB Interface(MSP-FET430UIF)or for the eZ430.5.Click Project→Rebuild All to build and link the source code.You can view the source code by double-clicking on the project,and then double-clicking on the displayed source file.6.Click Project→Debug to start the C-SPY debugger.C-SPY erases the device flash and thendownloads the application object file to the device flash.See FAQ Debugging#1if C-SPY is unable to communicate with the device.7.Click Debug→Go to start the application.The LED should flash.8.Click Debug→Stop Debugging to stop debugging,to exit C-SPY,and to return to the Workbench.9.Click File→Exit to exit the Workbench.Congratulations,you have just built and tested an MSP430application!1.3Important MSP430Documents on the CD-ROM and WebThe primary sources of MSP430information are the device-specific data sheet and user's guide.The most up-to-date versions of these documents that are available at the time of production are provided on the CD-ROM included with this tool.The MSP430web site(/msp430)contains the most recent version of these documents.PDF documents describing the IAR tools(Workbench and C-SPY,the assembler,the C compiler,thelinker,and the librarian)are in the common\doc and430\doc folders.Supplements to the documents(that is,the latest information)are available in HTML format in the same directories.430\doc\readme_start.htm provides a convenient starting point for navigating the IAR documentation.10Get Started Now!SLAU138AF–June2004–Revised June2014Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedChapter2SLAU138AF–June2004–Revised June2014Development Flow This chapter describes how to use KickStart to develop application software and how to use C-SPY to debug it.Topic Page2.1Overview (12)2.2Using KickStart (12)2.3Using C-SPY (19)11 SLAU138AF–June2004–Revised June2014Development Flow Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedOverview 2.1OverviewApplications are developed in assembler or C using the Workbench,and they are debugged using C-SPY.C-SPY is seamlessly integrated into the Workbench.However,it is more convenient to make thedistinction between the code development environment(Workbench)and the debugger(C-SPY).C-SPY can be configured to operate with the FET(that is,an actual MSP430device)or with a software simulator of the device.KickStart refers to the Workbench and C-SPY collectively.The KickStart software tools area product of IAR.Documentation for the MSP430family and KickStart is extensive.The CD-ROM supplied with this toolcontains a large amount of documentation describing the MSP430.The MSP430home page(/msp430)is another source of MSP430information.The components of KickStart(workbench and debugger,assembler,compiler,linker)are fully documented in<Installation Root>\EmbeddedWorkbench x.x\common\doc and<Installation Root>\Embedded Workbench\430\doc..htm files located throughout the KickStart directory tree contain the most up-to-date information and supplement the PDF files.In addition,KickStart documentation is available online via Help.Read Me First files from IAR and TI and this document can be accessed using Start→Programs→IAR Systems→IAR Embedded Workbench KickStart for MSP430V3.Tool User's Guide Most Up-To-Date Information Workbench,C-SPY EW430_UsersGuide.pdf readme.htm,ew430.htm,cs430.htm,cs430f.htmAssembler EW430_AssemblerReference.pdf a430.htm,a430_msg.htmCompiler EW430_CompilerReference.pdf icc430.htm,icc430_msg.htmC library CLibrary.htmLinker and Librarian xlink.pdf xlink.htm,xman.htm,xar.htm2.2Using KickStartThe KickStart edition is a special starter kit or evaluation version of IAR Embedded Workbench withlimitations both in code size and in the service and support that is provided.Limitations:•The C compiler does not generate an assembly code list file.•The code size limit of the MSP430IAR KickStart C/C++Compiler is set to4Kbytes for traditional MSP430devices and8Kbytes for MSP430X devices(see Table2-1for detailed information aboutwhich MSP430device is based on which architecture).•The IAR Assembler delivered is the full version without any restrictions.•The IAR XLINK Linker links a maximum of4Kbytes originating from C source code for traditional MSP430devices and8Kbytes for MSP430X devices(see Table2-1for detailed information aboutwhich MSP430device is based on which architecture),but an unlimited amount of code originatingfrom assembly code.•The IAR KickStart C-SPY Simulator reads a maximum of4Kbytes originating from C code for traditional MSP430devices and8Kbytes for MSP430X devices but is unlimited in the amount ofassembly code read(see Table2-1for detailed information about which MSP430device is based onwhich architecture).•MISRA C is not available.•The runtime library source code is not included.A full(that is,unrestricted)version of the software tools can be purchased from IAR.A mid-featured toolset–called Baseline,with a12Kbyte C-code size limitation and basic floating-point operations–is also available from IAR.See the IAR web site(www.iar.se)for more information.12Development Flow SLAU138AF–June2004–Revised June2014Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments Incorporated Using KickStart 2.2.1Project SettingsThe settings required to configure the Workbench and C-SPY are numerous and detailed.Read andthoroughly understand the documentation supplied by IAR when dealing with project settings.Review the project settings of the supplied assembler and C examples(the project settings are accessed usingProject→Options with the project name selected).Use these project settings as templates whendeveloping your own projects.Note that if the project name is not selected when settings are made,the settings are applied to the selected file(not to the project).The following project settings are recommended or required:•Specify the target device(General Options→Target→Device).•Enable an assembler project or a C or assembler project(General Options→Target→Assembler-only project).•Enable the generation of an executable output file(General Options→Output→Output file→Executable).•To most easily debug a C project,disable optimization[C/C++Compiler→Optimizations→Size→None(Best debug support)].•Enable the generation of debug information in the compiler output(C/C++Compiler→Output→Generate debug information).•Specify the search path for the C preprocessor(C/C++Compiler→Preprocessor→Include Paths).•Enable the generation of debug information in the assembler output(Assembler→Output→Generate Debug Info).•Specify the search path for the assembler preprocessor(Assembler→Preprocessor→Include Paths).•To debug the project using C-SPY,specify a compatible format[Linker→Output→Format→Debug information for C-SPY(with runtime control modules or with I/O emulation modules)].•Specify the search path for any used libraries(Linker→Config→Search paths).•Specify the C-SPY driver.Select Project→Options→Debugger→Setup→Driver→FET Debugger to debug on the FET(that is,MSP430device).Select Simulator to debug on the simulator.If FETDebugger is selected,use Project→Options→FET Debugger→Setup→Connection to select theappropriate port:Texas Instruments LPT-IF for the parallel FET Interface(MSP-FET430PIF)or TexasInstruments USB-IF for the USB Interface(MSP-FET430UIF)or for the eZ430.•Enable the Device Description file.This file makes C-SPY"aware"of the specifics of the device it is debugging.This file corresponds to the specified target device(Debugger→Setup→Devicedescription file→Override default).•Enable the erasure of the Main and Information memories before object code download(FET Debugger→Download→Erase main and Information memory).•To maximize system performance during debug,disable Virtual Breakpoints(FET Debugger→Breakpoints→Use virtual breakpoints)and disable all System Breakpoints(FET Debugger→Breakpoints→System breakpoints on).NOTE:Use Factory Settings to quickly configure a project.Use the Factory Settings button to quickly configure a project to a usable state.The following steps can be used to quickly configure a project.Note that the General Options tab does not have a Factory Settings button.1.Specify the target device(General Options→Target→Device).2.Enable an assembler project or a C or assembler project(General Options→Target→Assembler-only project).3.Enable the generation of an executable output file(General Options→Output→Output file→Executable).4.Accept the factory settings for the compiler(C/C++Compiler→Factory Settings).5.Accept the factory settings for the assembler(Assembler→Factory Settings).13 SLAU138AF–June2004–Revised June2014Development Flow Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedUsing KickStart 6.Accept the factory settings for the linker(Linker→Factory Settings).7.Accept the factory settings for C-SPY(Debugger→Factory Settings).8.Debug on the hardware(Debugger→Setup→Driver→FET Debugger).9.Specify the active parallel port used to interface to the FET if not LPT1(FET Debugger→Setup→Connection→Texas Instruments LPT-IF)or specify the USB port(FET Debugger→Setup→Connection→Texas Instruments USB-IF).NOTE:Avoid the use of absolute path names when referencing files.Instead,use the relative pathname keywords$TOOLKIT_DIR$and$PROJ_DIR$.See theIAR documentation for a description of these keywords.The use of relative path namespermits projects to be moved easily,and projects do not require modification when IARsystems are upgraded(for example,from KickStart or Baseline to Full).2.2.2Using Math Library for MSP430(MSPMathlib)in IAR EW4305.60.1and NewerTI's MSPMathlib is part of EW4305.60.1and newer releases.This optimized library provides up to26x better performance in applications that use floating point scalar math.For details,see the MSPMathlibweb page(/tool/mspmathlib).MSPMathlib may be enabled for new and existing projects on all supported devices.Enable or disable MSPMathlib in the project options(General Options→Library Configuration→MathLib).2.2.3Additional Project Settings for MSP430L092and MSP430C092The MSP430L092can operate in two different modes:L092mode and C092emulation mode.Thepurpose of the C092emulation mode is to behave like a C092with up to1920bytes of code at its final destination for mask generation.The operation mode is determined by EW430before starting the debugger.Two radio buttons areavailable for the mode selection.By default the L092mode is selected(see Figure2-1and Figure2-2).Figure2-1.L092Mode14Development Flow SLAU138AF–June2004–Revised June2014Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments Incorporated Using KickStartFigure2-2.C092Emulation Mode2.2.3.1MSP430L092Loader CodeThe Loader Code in the MSP430L092is a ROM-code from TI that provides a series of services.It enables customers to build autonomous applications without needing to develop a ROM mask.Such an application consists of an MSP430device containing the loader(for example,MSP430L092)and an SPI memorydevice(for example,'95512or'25AA40);these and similar devices are available from variousmanufacturers.The majority of use cases for an application with a loader device and external SPI memory for native0.9-V supply voltage are late development,prototyping,and small series production.Figure2-1shows the selection for loading the application into the external SPI memory.2.2.3.2Password Protection of MSP430C092The MSP430C092is a customer-specific ROM device that is protected by a password.To start a debug session,the password must be provided to EW430.Figure2-3shows how to provide a HEX password in EW430.Figure2-3.C092Password15 SLAU138AF–June2004–Revised June2014Development Flow Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments IncorporatedUsing KickStart 2.2.4Creating a Project From ScratchThis section presents step-by-step instructions to create an assembler or C project from scratch,and to download and run the application on the MSP430(see also Section2.2.1,Project Settings).The MSP430 IAR Embedded Workbench IDE User's Guide presents a more comprehensive overview of the process.1.Start the Workbench(Start→Programs→IAR Systems→IAR Embedded Workbench KickStart forMSP430V3→IAR Embedded Workbench).2.Create a new text file(File→New→File).3.Enter the program text into the file.NOTE:Use.h files to simplify your code development.KickStart is supplied with files that define the device registers and the bit names for eachdevice.These files can greatly simplify the task of developing your program.The files arelocated in<Installation Root>\Embedded Workbench x.x\430\inc.Include the.h filecorresponding to your target device in your text file(#include"msp430xyyy.h").Additionally,files io430xxxx.h are provided and are optimized to be included by C source files.4.Save the program text file(File→Save).It is recommended that assembler text files be saved with a file-type suffix of".s43"and that C text files be saved with a file-type suffix of".c".5.Create a new workspace(File→New→Workspace).6.Create a new project(Project→Create New Project).Select Tool chain:MSP430,Project Templates:Empty project and click OK.Specify a project name and click Save.7.Add the program text file to the project(Project→Add Files).Select the program text file and clickOpen.Alternatively,double-click on the file to add it to the project.NOTE:How to add assembler source files to your projectThe default file type presented in the Add Files window is"C/C++Files".To view assemblerfiles(.s43),select"Assembler Files"in the"Files of type"drop-down menu.8.Save the workspace(File→Save Workspace).Specify a workspace name and click Save.9.Configure the project options(Project→Options).For each of the subcategories(General Options,C/C++Compiler,Assembler,Linker,Debugger),accept the default Factory Settings with the followingexceptions:•Specify the target device(General Options→Target→Device).•Enable an assembler project or a C or assembler project(General Options→Target→Assembler-only project).•Enable the generation of an executable output file(General Options→Output→Output file→Executable).•To debug on the FET(that is,the MSP430),click Debugger→Setup→Driver→FET Debugger.•Specify the active port used to interface to the FET(FET Debugger→Setup→Connection).10.Build the project(Project→Rebuild All).11.Debug the application using C-SPY(Project→Debug).This starts C-SPY,and C-SPY takes control ofthe target,erases the target memory,programs the target memory with the application,and resets thetarget.See FAQ Debugging#1if C-SPY is unable to communicate with the device.12.Click Debug→Go to start the application.13.Click Debug→Stop Debugging to stop the application,to exit C-SPY,and to return to the Workbench.14.Click File→Exit to exit the Workbench.16Development Flow SLAU138AF–June2004–Revised June2014Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments Incorporated Using KickStart 2.2.5Additional Project Settings for Ultra-Low-Power Mode(LPMx.5)Debugging2.2.5.1What is LPMx.5LPMx.5is an ultra-low-power mode in which the entry and exit is handled differently than the other low-power modes.LPMx.5gives the lowest power consumption available on a device.To achieve this,entry to LPMx.5disables the LDO of the PMM module,which removes the supply voltage from the core and the JTAGmodule of the device.Because the supply voltage is removed from the core,all register contents andSRAM contents are lost.Exit from LPMx.5causes a BOR event,which forces a complete reset of thesystem.NOTE:The option"RELEASE JTAG ON GO"is currently not supported in the EmbeddedWorkbench when LPMx.5debugging is active.See the MSP430device family user's guidefor additional LPMx.5and ultra-low-power debug mode details.2.2.5.2Enable Ultra-Low-Power Debug ModeTo enable the ultra-low power debug mode feature the“Enable ULP/LPMx.5debug”checkbox must be enabled by clicking FET Debugger->Setup->Enable ULP/LPMx.5debug(see Figure2-4).When the ultra-low power debug mode is enabled a notification is displayed in the Debugger log every time thetarget device enters and leaves LPMx.5mode(see Figure2-5).Press the Halt or Reset button in Embedded Workbench to wake up the target device from LPMx.5.Execution of the code is halted at the start of the program.All breakpoints that had been active beforeLPMx.5are restored and reactivated automatically.Figure2-4.Enable Ultra-Low-Power Debug Mode17 SLAU138AF–June2004–Revised June2014Development Flow Submit Documentation FeedbackCopyright©2004–2014,Texas Instruments Incorporated。
指令集描述P(220—257)* DECX.A目的操作数减1* DECX.[W] 目的操作数减1* DECX.B 目的操作数减1语法DECV.A dstDECX dst 或DECX.W dstDECX.B dst操作dst – 1 →dst仿真SUBX.A#1,dstSUBX #1,dstSUBX.B #1,dst说明目的操作数减1 以前的内容丢失状态位N :结果为负时置位为正时复位Z : dst包含1时置位其他情况时复位C : dst包含0时置位其他情况时复位V : 产生算术溢出时置位其他情况时复位目的操作数的初始值为08000H时置位其他情况时复位方式位OscOff(晶振控制位),CPUOff(CPU控制位)和GIE(中断标志位)不受影响例子目的地址操作数减一DECX.A TONI ; TONI减一* DECDX.[W] 目的操作数减2* DECDX.B 目的操作数减2语法DECDX.A dstDECDX dst or DECDX.W dsDECDX.B dst操作dst - 2 -> dst仿真SUBX.A#2,dstSUBX #2,dstSUBX.B #2,dst说明目的操作数减2 以前的内容丢失状态位N : 结果为负时置位为正时复位Z : dst包含2时置位其他情况时复位C : dst包含0或1时置位其他情况时复位V : dst产生算术溢出时置位其他情况时复位目的操作数的初始值为08001H或08000H时置方式位OscOff, CPUOff 和GIE不受影响例子目的地址操作数减二DECDX.A TONI ; Decrement TONI* INCX.[W] 目的操作数加1* INCX.B 目的操作数加1语法INCX.A dstINCX dst or INCX.W dstINCX.B dst操作dst + 1 →dst仿真ADDX.A#1,dstADDX #1,dstADDX.B #1,dst说明目的操作数加1 以前的内容丢失状态位N : 结果为负时置位为正时复位Z : dst包含0FFFFFH时置位其他情况时复位dst包含0FFFFH时置位其他情况时复位dst包含0FFFH时置位其他情况时复位C: dst包含0FFFFFH时置位其他情况时复位dst包含0FFFFH时置位其他情况时复位dst包含0FFFH时置位其他情况时复位V : dst包含07FFFH时置位其他情况时复位dst包含07FFFH时置位其他情况时复位dst包含07FH时置位其他情况时复位方式位OscOff ,CPUOff 和GIE不受影响例子目的地址操作数加一INCX.A TONI ; Increment TONI (20-bits)* INCDX.A目的操作数加2* INCDX.[W] 目的操作数加2* INCDX.B 目的操作数加2语法INCDX.A dstINCDX dst or INCDX.W dstINCDX.B dst操作dst + 1 →dst仿真ADDX.A#2,dstADDX #2,dstADDX.B #2,dst说明目的操作数加2以前的内容丢失状态位N: 结果为负时置位为正时复位Z : dst包含0FFFFEH时置位其他情况时复位dst包含0FFFEH时置位其他情况时复位dst包含0FEH时置位其他情况时复位C: dst包含0FFFFEH或0FFFFFH时置位其他情况时复位dst包含0FFFEH或0FFFFH时置位其他情况时复位dst包含0FEH或0FFH时置位其他情况时复位V: dst包含07FFFEH或0FFFFH时置位其他情况时复位dst包含07FFEH或0FFFH时置位其他情况时复位dst包含07EH或0FH时置位其他情况时复位方式位OscOff ,CPUOff 和GIE不受影响例子目的地址操作数加二INCDX.B LEO ; Increment LEO by two* INVX.A目的操作数求反* INVX.[W] 目的操作数求反* INVX.B 目的操作数求反语法INVX.A dstINVX dst or INVX.W dstINVX.B dst操作.NOT.dst →dst仿真XORX.A#0FFFFFh,dstXORX #0FFFFh,dstXORX.B #0FFh,dst说明目的操作数取反以前的内容丢失状态位N : 结果为负时置位为正时复位Z :dst 包含0FFFFFH时置位其他情况时复位dst 包含0FFFFH时置位其他情况时复位dst 包含0FFH时置位其他情况时复位C :结果不为零时置位其他情况时复位( = .NOT.Zero )V 初始目的操作数为负时置位其他情况时复位方式位OscOff CPUOff 和GIE不受影响例子R5 求反INVX.A R5 ; R5求反MOVX.A源操作数移至目的操作数MOVX.[W] 源操作数移至目的操作数MOVX.B 源操作数移至目的操作数语法MOVX.A src,dstMOVX src,dst or MOVX.W src,dstMOVX.B src,dst操作src →dst说明源操作数被移至目的操作数源操作数不受影响目的操作数以前的内容丢失状态位N: 不影响状态位Z: 不影响状态位C: 不影响状态位V: 不影响状态位方式位OscOff ,CPUOff 和GIE不受影响例子移动18000H 到EDEMOVX. A#018000h, &EDE ; Move 18000h to EDE例子地起码表EDE(字数据)的内容被复制到表TOM 地址表的长度为030H MOV #EDE, R10 ;准备指针Loop MOV @R10+, TOM-EDE-2(R10) ;将R10 中的指针用于两表DEC R9 ;计数器减1JNZ Loop ;计数器<>0 继续........ ;完成例子地起码表EDE(字数据)的内容被复制到表TOM 地址表的长度为020H MOV #EDE, R10 ;准备指针MOV #020H, R9 ;计数器Loop MOV @R10+, TOM-EDE-2(R10) ;将R10 中的指针用于两表DEC R9 ;计数器减1JNZ Loop ;计数器<>0 继续........ ;完成28种MOVX寻址方式中的10种,一个指令可以使用MOVX,这样可以节省二个字节编码周期。
T EXAS I NSTRUMENTSMSP430系列混合信号微控制器结构及模块用户指南目录1MSP430系列1.1特性与功能1.2系统关键性能1.3MSP430系列的各型号2结构概述2.1CPU2.2代码存储器2.3数据存储器(RAM)2.4运行控制2.5外围模块2.6振荡器、倍频器和时钟发生器3系统复位、中断和运行模式3.1系统复位和初始化3.2中断系统结构3.3中断处理3.3.1SFR中的中断控制位3.3.2外部中断3.4运行模式3.5低功耗模式3.5.1 低功耗模式0与模式1,LPM0和LPM1 3.5.2 低功耗模式2与模式3,LPM2和LPM3 3.5.3 低功耗模式4,LPM43.6 低功耗应用要点4 存储器组织4.1 存储器中的数据4.2 片内ROM组织4.2.1 ROM表的处理4.2.2 计算分支跳转和子程序调用4.3 RAM与外围模块组织4.3.1 RAM4.3.2 外围模块—地址定位4.3.3 外围模块--SFR5 16位CPU5.1 CPU寄存器5.1.1 程序计数器PC5.1.2 系统堆栈指针SP5.1.3 状态寄存器SR5.1.4 常数发生寄存器CG1与CG25.2 寻址模式5.2.1 寄存器模式5.2.2 变址模式5.2.3 符号模式5.2.4 绝对模式5.2.5 间接模式5.2.6 间接增量模式5.2.7 立即模式5.2.8 指令的时钟周期与长度5.3 指令组概述5.3.1 双操作数指令5.3.2 单操作数指令5.3.3 条件跳转5.3.4 模拟指令的短格式5.3.5 其它指令5.4 指令分布6 硬件乘法器6.1 硬件乘法器的操作6.2 硬件乘法器的寄存器6.3 硬件乘法器的SFR位6.4 硬件乘法器的软件限制6.4.1 硬件乘法器软件限制--寻址模式 6.4.2 硬件乘法器软件限制--中断程序7 振荡器与系统时钟发生器7.1 晶体振荡器7.2 处理机时钟发生器7.3 系统时钟运行模式7.4 系统时钟控制寄存器7.4.1 模块寄存器7.4.2 与系统时钟发生器相关的SFR位 7.5 DCO典型特性8 数字I/O配置8.1 通用端口P08.1.1 P0控制寄存器8.1.2 P0原理图8.1.3 P0中断控制功能8.2 通用端口P1、P28.2.1 P1、P2控制寄存器8.2.2 P1、P2原理图8.2.3 P1、P2中断控制功能8.3 通用端口P3、P48.3.1 P3、P4控制寄存器8.3.2 P3、P4原理图8.4 LCD端口8.5 LCD端口--定时器/端口比较器9 通用定时器/端口模块9.1 定时器/端口模块操作9.1.1 定时器/端口计数器TPCNT1,8位操作 9.1.2 定时器/端口计数器TPCNT2,8位操作 9.1.3 定时器/端口计数器,16位操作9.2 定时器/端口寄存器9.3 定时器/端口SFR位9.4 定时器/端口在A/D中的应用9.4.1 R/D转换原理9.4.2 分辨率高于8位的转换10 定时器10.1 Basic Timer110.1.1 BasicTimer1寄存器10.1.2 SFR位10.1.3 BasicTimer1操作10.1.4 BasicTimer1操作:LCD时钟信号f LCD 10.2 8位间隔(Interval)定时器/计数器 10.2.1 8位定时器/计数器的操作10.2.2 8位定时器/计数器的寄存器10.2.3 与8位定时器/计数器有关的SFR 10.2.4 8位定时器/计数器在UART中的应用 10.3 看门狗定时器10.3.1 看门狗定时器寄存器10.3.2 看门狗定时器中断控制功能10.3.3 看门狗定时器操作10.4 8位PWM定时器10.4.1 操作10.4.2 PWM寄存器11 Timer_A11.1 Timer_A的操作11.1.1 定时器操作11.1.2 捕获模式11.1.3 比较器模式11.1.4 输出单元11.2 Timer_A的寄存器11.2.1 Timer_A控制寄存器TACTL11.2.2 捕获/比较控制寄存器CCTL11.2.3 Timer_A中断向量寄存器11.3 Timer_A的应用11.3.1 Timer_A增计数模式应用11.3.2 Timer_A连续模式应用11.3.3 Timer_A增/减计数模式应用11.3.4 Timer_A软件捕获应用11.3.5 Timer_A处理异步串行通信协议 11.4 Timer_A的特殊情况11.4.1 CCR0用作周期寄存器11.4.2 定时器寄存器的启/停11.4.3 输出单元Unit012 USART外围接口,UART模式12.1 异步操作12.1.1 异步帧格式12.1.2 异步通信的波特率发生器12.1.3 异步通信格式12.1.4 线路空闲多处理机模式12.1.5 地址位格式12.2 中断与控制功能12.2.1 USART接收允许12.2.2 USART发送允许12.2.3 USART接收中断操作12.2.4 USART发送中断操作12.3 控制与状态寄存器12.3.1 USART控制寄存器UCTL12.3.2 发送控制寄存器UTCTL12.3.3 接收控制寄存器URCTL12.3.4 波特率选择和调制控制寄存器12.3.5 USART接收数据缓存URXBUF12.3.6 USART发送数据缓存UTXBUF12.4 UART模式,低功耗模式应用特性 12.4.1 由UART帧启动接收操作12.4.2 UART模式波特率与时钟频率12.4.3 节约MSP430资源的多处理机模式 12.5 波特率的计算13 USART外围接口,SPI模式13.1 USART的同步操作13.1.1 SPI模式中的主模式,MM=1、SYNC=1 13.1.2 SPI模式中的从模式,MM=0、SYNC=1 13.2 中断与控制功能13.2.1 USART接收允许13.2.2 USART发送允许13.2.3 USART接收中断操作13.2.4 USART发送中断操作13.3 控制与状态寄存器13.3.1 USART控制寄存器13.3.2 发送控制寄存器UTCTL13.3.3 接收控制寄存器URCTL13.3.4 波特率选择和调制控制寄存器 13.3.5 USART接收数据缓存URXBUF 13.3.6 USART发送数据缓存UTXBUF14 液晶显示驱动14.1 LCD驱动基本原理14.2 LCD控制器/驱动器14.2.1 LCD控制器/驱动器功能14.2.2 LCD控制及模式寄存器14.2.3 LCD显示存储器14.2.4 LCD操作软件例程14.3 LCD端口功能14.4 LCD与端口模式混合应用实例15 A/D转换器15.1 概述15.2 A/D转换操作15.2.1 A/D转换15.2.2 A/D中断15.2.3 A/D量程15.2.4 A/D电流源15.2.5 A/D输入端与多路切换15.2.6 A/D接地与降噪15.2.7 A/D输入与输出引脚15.3 A/D控制寄存器16 其它模块16.1 晶体振荡器16.2 上电电路16.3 晶振缓冲输出附录A 外围模块分布附录B 指令组说明附录C EPROM编程本书用途及表述约定MSP430用户指南以方便工程师及程序员使用的方式提供软件和硬件资料,以帮助开发应用MSP430系列的产品。
12.1Timer_A Introductiontimer_a是一个16位定时器/计数器三捕获/比较寄存器。
timer_a可以支持多个捕获/比较,脉宽调制输出,和间隔时间。
timer_a也拥有丰富的中断能力。
中断可能产生的计数器溢出条件,从每一个的捕获/比较寄存器timer_a功能包括:•异步的16位定时器/计数器具有四种操作模式•可选和可配置的时钟源•两或三个可配置捕获/比较寄存器•配置的输出PWM能力•异步输入和输出锁存•中断向量寄存器的快速解码所有的timer_a中断timer_a框图见图12-1。
注意:使用单词计数计数是在本章中使用。
这意味着计数器必须在计数的过程中采取行动。
如果一个特定的值是直接写入计数器,一个相关的行动将不会发生。
12.2Timer_A Operation该timer_a模块配置与用户软件。
安装和操作timer_a讨论以下部分。
12.2.116-Bit Timer Counter16位定时器/计数器寄存器,TAR,递增或递减(取决于操作模式)与每个时钟的上升沿信号。
TAR可以读或写软件。
此外,当它溢出时该定时器产生一个中断。
TAR可清除设置TACLR位。
设置TACLR清除时钟分频器和计数向上/下模式。
注:修改timer_a寄存器在修改其运作之前建议停止计时器(除了中断使能和中断标志),避免错误的操作情况。
当定时器时钟异步处理器的时钟时,任何读从TAR中有可能发生当计时器不工作或结果可能是不可预测的。
另外,该定时器可多次读取操作时,与多数表决采取软件确定正确的阅读。
任何写入TAR将立即生效。
12.2.1.1Clock Source Select and Divider12.2.1.1时钟源选择和分频器计时器时钟的来源可以从ACLK,SMCLK,或通过外部TACLK或INCLK。
时钟源选择与TASSELx 位。
选定的时钟源可直接传递给定时器或除以2,4,或8,使用IDx的位。
msp430芯片选型中文手册指南F1XX系列Vcc1.8V-3.6V型号MSP430F1101A参数说明1KBflash,128BRam;slopeA/D;14个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器),比较器_A;20DW、PW封装型号MSP430F1111A参数说明2KBflash,128BRam;slopeA/D;14个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器),比较器_A;20DW、PW封装型号MSP430F1121A参数说明4KBflash,256BRam;slopeA/D;14个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器),比较器_A;20DW、PW封装型号MSP430F1122参数说明4KBflash,256BRam;5通道10bitA/D;14个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器),温度传感器;20DW、PW封型号MSP430F1132参数说明8KBflash,256BRam;5通道10bitAD;14个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);温度传感器;20DW、PW封型号MSP430F122参数说明4KBflash,256BRam;slopeA/D;22个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个USART接口,比较器A;28DW、PW封装型号MSP430F123参数说明8KBflash,256BRam;slopeA/D;22个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个USART接口,比较器A;28DW、PW封装型号MSP430F1222参数说明4KBflash,256BRam;8通道10bitA/D;22个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个USART接口;温度传感器;28DW、PW封装型号MSP430F1232参数说明8KBflash,256BRam;8通道10bitA/D;22个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个USART接口;温度传感器;28DW、PW封装型号MSP430F133参数说明8KBflash,256BRam;8通道12bitA/D;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(3个捕获/比较寄存器);1个USART接口;比较器_A;温度传感器;64PM封装型号MSP430F135参数说明16KBflash,512BRam;8通道12bitA/D;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(3个捕获/比较寄存器);1个USART接口;比较器_A;温度传感器;64PM封装型号MSP430F147参数说明32KBflash,1024BRam;8通道12bitA/D;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;MPY;比较器_A;温度传感器;64PM封装型号MSP430F1471参数说明32KBflash,1024BRam;slopeA/D;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;MPY;比较器_A;64PM封装型号MSP430F148参数说明48KBflash,2048BRam;8通道12bitA/D;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;MPY;比较器_A;温度传感器;64PM封装型号MSP430F1481参数说明48KBflash,2048BRam;slopeA/D;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;MPY;比较器_A;64PM封装型号MSP430F149参数说明60KBflash,2048BRam;8通道12bitA/D;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;MPY;比较器_A;温度传感器;64PM封装型号MSP430F1491参数说明60kflash,2048BRam;slopeA/D;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;MPY;比较器_A;64PM封装型号MSP430F155参数说明16KBflash,512BRam;8通道12bitA/D;双12bitD/A;DMA;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(3个捕获/比较寄存器);1个USART接口;I2C;比较器_A;温度传感器;64PM封装型号MSP430F156参数说明24KBflash,512BRam;8通道12bitA/D;双12bitD/A;DMA;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(3个捕获/比较寄存器);1个USART接口;I2C;比较器_A;温度传感器;64PM封装型号MSP430F157参数说明32KBflash,1024BRam;8通道12bitA/D;双12bitD/A;DMA;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(3个捕获/比较寄存器);1个USART接口;I2C;比较器_A;温度传感器;64PM封装型号MSP430F167参数说明32KBflash,1024BRam;8通道12bitA/D;双12bitD/A;DMA;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;I2C;MPY;比较器_A;温度传感器;64PM封装型号MSP430F168参数说明48KBflash,2048BRam;8通道12bitA/D;双12bitD/A;DMA;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;I2C;MPY;比较器_A;温度传感器;64PM封装型号MSP430F169参数说明60KBflash,2048BRam;8通道12bitA/D;双12bitD/A;DMA;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;I2C;MPY;比较器_A;温度传感器;64PM封装型号MSP430F1610参数说明32KBflash,5120BRam;8通道12bitA/D;双12bitD/A;DMA;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;I2C;MPY;比较器_A;温度传感器;64PM封装型号MSP430F1611参数说明48KBflash,10240BRam;8通道12bitA/D;双12bitD/A;DMA;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B (7个捕获/比较寄存器);2个USART接口;I2C;MPY;比较器_A;温度传感器;64PM封装型号MSP430F1612参数说明55kBflash,5120BRam;8通道12bitA/D;双12bitD/A;DMA;48个I/O口;16位WDT;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;I2C;MPY;比较器_A;温度传感器;64PM封装F21X1系列Vcc1.8V-3.6V型号MSP430F2101参数说明1KBflash,128BRam;slopeA/D;16个I/O口;15/16位WDT;1个16位Timer_A(3个捕获/比较寄存器);比较器_A;BrownoutProtection;20DW、PW、DGV封装型号MSP430F2111参数说明2KBflash,128BRam;slopeA/D;16个I/O口;15/16位WDT;1个16位Timer_A(3个捕获/比较寄存器);比较器_A;BrownoutProtection;20DW、PW、DGV封装型号MSP430F2121参数说明4KBflash,256BRam;slopeA/D;16个I/O口;15/16位WDT;1个16位Timer_A(3个捕获/比较寄存器);比较器_A;BrownoutProtection;20DW、PW、DGV封装型号MSP430F2131参数说明8KBflash,256BRam;slopeA/D;16个I/O口;15/16位WDT;1个16位Timer_A(3个捕获/比较寄存器);比较器_A;BrownoutProtection;20DW、PW、DGV封装F4XX系列Vcc1.8V-3.6VWithLCD驱动型号MSP430F412参数说明4KBflash,256BRam;slopeA/D;48个I/O口;96段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);比较器_A;64PM封装型号MSP430F413参数说明8KBflash,256BRam;slopeA/D;48个I/O口;96段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);比较器_A;64PM封装型号MSP430F415参数说明16kBflash,512BRam;slopeA/D;48个I/O口;96段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3或5个捕获/比较寄存器);比较器_A;64PM 封装型号MSP430F417参数说明32kBflash,1024BRam;slopeA/D;48个I/O口;96段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3或5个捕获/比较寄存器);比较器_A;64PM 封装型号MSP430FE423参数说明8KBflash,256BRam;SD16A/D;Emeter计量模块;14个I/O口;128段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);1个USART接口;温度传感器;64PM封装型号MSP430FE425参数说明16KBflash,512BRam;SD16A/D;Emeter计量模块;14个I/O口;128段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);1个USART接口;温度传感器;64PM封装型号MSP430FE427参数说明32KBflash,1KBRam;SD16A/D;Emeter计量模块;14个I/O口;128段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);1个USART接口;比较器_A;温度传感器;64PM封装型号MSP430F4250参数说明16KBflash,256BRam;32个I/O口;56段LCD;SD16位ADC (具有内部参考电压);12位DAC,1个16位Timer_A(3个捕获/比较寄存器);温度传感器模块;电源检测功能;48DL封装型号MSP430F4260参数说明24KBflash,256BRam;32个I/O口;56段LCD;SD16位ADC (具有内部参考电压);12位DAC,1个16位Timer_A(3个捕获/比较寄存器);温度传感器模块;电源检测功能;48DL封装型号MSP430F4270参数说明32KBflash,256BRam;32个I/O口;56段LCD;SD16位ADC (具有内部参考电压);12位DAC,1个16位Timer_A(3个捕获/比较寄存器);温度传感器模块;电源检测功能;48DL封装型号MSP430FG437参数说明32KBflash,1024BRam;12通道12bitA/D;双12bitD/A;48个I/O口;DMA;128段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(3个捕获/比较寄存器);1个USART接口;温度传感器;80PN 封装型号MSP430FG438参数说明48KBflash,2048BRam;12通道12bitA/D;双12bitD/A;48个I/O口;DMA;128段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(3个捕获/比较寄存器);1个USART接口;温度传感器;80PN 封装型号MSP430FG439参数说明60KBflash,2048BRam;12通道12bitA/D;双12bitD/A;48个I/O口;DMA;128段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(3个捕获/比较寄存器);1个USART接口;温度传感器;80PN 封装型号MSP430FW423参数说明8KBflash,256BRam;slopeA/D;流量测量ScanIF模块;48个I/O口;96段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3或5个捕获/比较寄存器);比较器_A;64PM封装型号MSP430FW425参数说明16KBflash,512BRam;slopeA/D;流量测量ScanIF模块;48个I/O口;96段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3或5个捕获/比较寄存器);比较器_A;64PM封装型号MSP430FW427参数说明32KBflash,1024BRam;slopeA/D;流量测量ScanIF模块;48个I/O口;96段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3或5个捕获/比较寄存器);比较器_A;64PM封装型号MSP430F435参数说明16KBFlash,512BRam;8通道12bitA/D;48个I/O口;128/160段LCD;16位WDT;8bit基本定时器;16位Timer_A(3个捕获/比较寄存器)_A;16位Timer_B(3个捕获/比较寄存器)_B;1个USART接口;比较器_A;温度传感器;80PN/100PZ封装型号MSP430F436参数说明24KBFlash,1024KRam;8通道12bitA/D;48个I/O口;128/160段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(3个捕获/比较寄存器)_B;1个USART接口;比较器_A;温度传感器;80PN/100PZ封装型号MSP430F437参数说明32KBFlash,1024KRam;8通道12bitA/D;48个I/O口;128/160段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器)_A;1个16位Timer_B(3个捕获/比较寄存器)_B;1个USART接口;比较器_A;温度传感器;80PN/100PZ封装型号MSP430F447参数说明32KBFlash,1024KRam;8通道12bitA/D;48个I/O口;160段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;MPY;比较器_A;温度传感器;100PZ 封装型号MSP430F448参数说明48KBflash,2048BRam;8通道12bitA/D;48个I/O口;160段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;MPY;比较器_A;温度传感器;100PZ 封装型号MSP430F449参数说明60KBflash,2048BRam;8通道12bitA/D;48个I/O口;160段LCD;16位WDT;8bit基本定时器;1个16位Timer_A(3个捕获/比较寄存器);1个16位Timer_B(7个捕获/比较寄存器);2个USART接口;MPY;比较器_A;温度传感器;100PZ 封装型号TSS721AD参数说明M-BUS总线型号TRF6901PT参数说明无线射频率收发芯片。
MSP430F2系列16位超低功耗单片机模块原理第15章Compare A+ 比较器A+版本: 1.2日期: 2007.7.原文: TI MSP430x2xxfamily.pdf翻译: 欧浩源中国计量学院编辑: DC 微控技术论坛版主注:以下文章是翻译TI MSP430x2xxfamily.pdf 文件中的部分内容。
由于我们翻译水平有限,有整理过程中难免有所不足或错误;所以以下内容只供参考.一切以原文为准。
详情请密切留意微控技术论坛。
Page 1 of 10第15章比较器A比较器A是一个模拟电压比较器。
这一章描述的是比较器A。
在MSP430x2xx系列中,除了MSP430x20x0和MSP430x22x4的所有设备均具有该比较器。
主题比较器A概述比较器A操作比较器A的寄存器15.1比较器A概述比较器A模块支持精确的斜率数模转换,电压监控和外部模拟信号的监控。
比较器A的特点如下:n反向和非反向的终端输入复用器。
n比较器输出有软件选择的RC滤波器。
n比较器的输出可以作为定时器A的捕获输入。
n端口输入缓冲由软件控制。
n具有中断功能。
n可选择的参考电压发生器。
n比较器和参考电压发生器可关闭。
n多路输入选择器。
比较器A的结构框图如图15-1所示。
Page 2 of 1015.2比较器A操作比较器A模块可以通过软件来进行设置。
该比较器的设置和操作通过下面几个部分来进行讨论。
15.2.1比较器比较器比较正端和负端输入的模拟电压。
如果正端的电压高于负端的电压,比较器输出CAOUT 为高。
通过控制位CAON可以打开或者关闭比较器。
比较器不使用时应该将其关闭以减小消耗电流。
当比较器关闭时,CAOUT总是输出低电平。
15.2.2输入模拟开关通过P2CAx位可以控制模拟输入开关,使两个比较器的输入端连接到或者不连接到相关的端口管脚。
比较器的两个输入端可以单独的控制。
P2CAx位允许下面的操作:n将外部的信号应用到比较器的正负两端。
n将一个内部参考电压连接到相应的输出端口管脚。
在内部,输入开关使T型开关结构的,这样可以抑制信号链路上的失真。
注释:比较器输入连接。
当比较器打开时,其输入端应该连接到信号源、电源或者地。
否则,悬空会产生意想不到的中断以及增加电流的消耗。
Page 3 of 10Page 4 of 10CAEX 位控制输入多路复用器,交换连接到比较器正端和负端的输入信号。
另外,当比较器两端的信号被交换时,比较器的输出信号会被反转。
这样允许用户测定或者补偿比较器输入的偏移电压。
15.2.3 输入短路开关CASHORT 位短路比较器A 的输入。
它可以用来为比较器建立一个简单的采样保持器,如图15-2所示。
需要的采样时间和采样电容(C S )、带有短路开关的输入开关序列的电阻(R i )和外部信号源的阻抗(R S )的大小成比例。
总共的内部阻抗的典型范围时2到10千欧。
采样电容C S 应该大于100皮法。
改变采样电容C S ,可以通过下面的公式计算时间常数Tau :根据需要的精度,应该用3到5倍的Tau 的时间作为采样时间。
3倍的Tau 采样电容大约可以对输入信号电压进行95%的充电。
5倍的Tau 采样电容可以对输入信号电压进行大于99%的充电。
10倍的Tau 采样的电压可以充分满足12位的精度要求。
15.2.4 输出滤波器比较器的输出可以使用内部的滤波器,也可以不使用。
当控制位CAF 位置位时,输出通过片上的RC 低通滤波器进行滤波。
如果差分电压通过输入端很小,则任何的比较器的输出都会产生振荡。
内部和外部的寄生作用以及信号线、电源线和系统的其他部分产生的耦合都会导致图15-3的行为。
比较器输出的振荡会降低比较结果精确度和解析度。
选择输出滤波会减少由于比较器振荡引起的错误。
15.2.5参考电压发生器参考电压发生器用来产生电压V CAREF,该电压提供给比较器的每个输入端。
CAREFx位控制电压发生器的电压输出。
CARSEL位选择比较器端使用那个V CAREF。
如果比较器的两个输入端都使用外部输入信号,那么内部参考电压应该关闭以降低电流的消耗。
该参考电压发生器能够产生部分的设备V CC或者确定的发送器~0.55V的门限电压。
15.2.6比较器A端口禁用寄存器CAPD比较器的输入和输出功能和相关的端口管脚复合使用,这些管脚都是数字CMOS门结构的。
当模拟信号加载到数字CMOS门时,会产生从V CC流向GND的寄生电流。
如果输入电压竭尽门的转换电压就会出现寄生电流。
禁止端口管脚缓冲区能够消除寄生电流的流动,从而可以减少整个电流的消耗。
当CAPDx位被置位时,相应的P1端口输入和输出缓冲器如图15-4所示。
当对电流的消耗非常敏感时,任何连接到模拟信号的管脚都应该通过CAPDx位禁止。
通过P2CAx位为比较器复用器选择输入管脚时,不管其对应的CAPDx位状态如何,该管脚的输入和输出缓冲区都会自动禁止。
15.2.7比较器A的中断如图15-5所示,与比较器相关的有一个中断标志一个中断向量。
比较器输出的上升沿或者时下降沿都会使中断标志CAIFG置位,输出的上升沿还是下降沿产生中断可以通过CAIES位选择。
如果CAIE和GIE同时置位,随后CAIFG则会产生一个中断请求。
当中断请求被响应CAIFG位会自动复位,通过软件该位也会复位。
Page 5 of 10Page 6 of 1015.2.8 比较器A 用于测量电阻元件利用模拟数字转换的信号斜坡,比较器A 能够精确的测量电阻元件。
例如,如图15-5所示,利用热敏电阻,通过比较热敏电阻电容和参考电阻电容的放电时间,可以将温度转换成数字信号。
参考电阻R ref与R meas 进行比较。
下面是通过R meas 计算温度传感所使用的MSP430的资源: n 两个数字I/O 端口,用来对电容进行充电和放电。
n I/O 端口置位输出高电平(V CC )对电容进行充电,复位则对其放电。
n I/O 端口不使用时通过置位CAPDx 位使其切换到高阻态输出。
n 一个输出通过R ref 对电容进行充放电。
n 一个端口通过R meas 对电容进行充放电。
n 比较器的正端连接到电容的正极。
n 比较器的负端连接到参考电平,例如0.25×V CC 。
n 使用滤波器输出使其噪声减到最小。
n CAOUT 使用门控制Timer_A CCI1B 捕获电容放电的时间。
多于一个电阻元件也可以被测量。
另外的一个元件通过可以使用的I/O 端口连接到CA0。
当其不进行测量的时候该端口管脚切换到高阻态。
热敏电阻的测量是基于传感器测量转换原理的。
两个电容放电时间的计算如图15-7所示:Page 7 of 10在转换的过程中,电源电源V CC 和电容值应该保持恒定值不变,但是当他们在分数中可以抵消是不是很关键。
15.3 比较器A 的寄存器在表15-1中列出了比较器A 的寄存器。
寄存器格式 寄存器类型 地址 初始状态 比较器A+ 控制寄存器1 CACTL1 读/写 059h 复位 和 POR 比较器A+ 控制寄存器2 CACTL2 读/写 05Ah 复位 和 POR 比较器A+ 禁止寄存器 CAPD读/写05Bh复位 和 PORPage 8 of 10CACTL1,比较器控制寄存器1CAEX : 位7 交换比较器的输入端。
该位交换比较器的输入信号和反转比较器的输出。
CARSEL: 位6 比较器参考选择。
该位选择V CAREF 被用于那一端。
当CAEX=0时:0 V CAREF 用于正端。
1 V CAREF 用于负端。
当CAEX=1时:0 V CAREF 用于负端。
1 V CAREF 用于正端。
CAREF :位5-4 比较器A 参考选择。
该位选择参考电压V CAREF 。
00 内部参考电源关闭。
使用外部参考电源。
01 选择0.25V CC 作为参考电压。
02 选择0.5V CC 作为参考电压。
03 选择二极管电压作为参考电压。
CAON :位3 比较器开关控制。
该位可以打开比较器。
当比较器关闭的时,它几乎不消耗电流。
其参考电路可以独立的使能或者禁止。
0 关闭。
1 打开。
CAIES :位2 比较器A 的中断触发沿选择。
0 上升沿。
1 下降沿。
CAIE :位1 比较器A 的中断使能。
0 禁止。
1 使能。
CAIFG :位0 比较器A 的中断标志。
0 没有中断请求。
1 有中断请求。
CACTL2,比较器控制寄存器2CASHORT : 位7 输入短路。
该位将输入的正端和负端短路。
0 输入没被短路。
1 输入被短路。
P2CA4:位6 输入选择。
该位结合P2CA0,在CAEX=0时选择正端的输入,在CAEX=1时选择负端的输入。
P2CA3:位5-3 输入选择。
P2CA2:当CAEX=0时选择负端的输入,当CAEX=1时选择正端的输入。
P2CA1:000 没有连接。
001 CA1010 CA2011 CA3100 CA4101 CA5110 CA6111 CA7P2CA0:位2 输入选择。
该位结合P2CA4,在CAEX=0时选择正端输入,在CAEX=1时选择负端输入。
00无连接。
01CA0。
10CA1。
11CA2。
CAF:位1 比较器输出滤波。
0比较器输出不经过滤波器。
1比较器输出经过滤波器。
CAOUT:位0 比较器A的输出。
该位反映比较器输出的值,对该位进行写操作无效。
CAPA,比较器A端口禁止寄存器CAPDx:位7-0 比较器A端口禁止。
这些位可以独立的禁止与比较器A相连端口管脚的输入缓冲区。
例如,如果CA0是连在管脚P2.3上的,CAPDx位可以用来独立的使能或者是禁止每个P2.x的管脚缓冲区。
CAPD0禁止P2.0,CAPD1禁止P2.1等等。
0输入缓冲区使能。
1输入缓冲区禁止。
Page 9 of 10MSP430F22x4评估板专业提供MSP430单片机开发工具Page 10 of 10MSP430F2系列16位超低功耗单片机模块原理第15章Compare A+ 比较器A+版本: 1.2日期: 2007.7.原文: TI MSP430x2xxfamily.pdf翻译: 欧浩源中国计量学院编辑: DC 微控技术论坛版主注:以下文章是翻译TI MSP430x2xxfamily.pdf 文件中的部分内容。
由于我们翻译水平有限,有整理过程中难免有所不足或错误;所以以下内容只供参考.一切以原文为准。
详情请密切留意微控技术论坛。
Page 1 of 10第15章比较器A比较器A是一个模拟电压比较器。
这一章描述的是比较器A。
在MSP430x2xx系列中,除了MSP430x20x0和MSP430x22x4的所有设备均具有该比较器。
主题比较器A概述比较器A操作比较器A的寄存器15.1比较器A概述比较器A模块支持精确的斜率数模转换,电压监控和外部模拟信号的监控。