mc9s12xs128内存详解
Freescale Semiconductor Application Note Document Number: AN3497Rev. 0, 07/2007 Contents1IntroductionThe S12XS family is a next generation, cost competitive MCU solution targeting existing S12 customers and emerging markets. The S12XS family features a power- and code-efficient 16-bit core, on-board data flash(D-flash), an on-board frequency-modulated PLL, and offers flexibility and compatibility with the fully featured S12XE family.Target applications include smart junction boxes, seat controllers, HV AC, low-end engine control, body ECU, RKE receiver, door modules, and steering modules. The S12XS is pin compatible and emulatable with the XE family. Key features of the XE-family that are not included on XS family are: XGATE coprocessor, memory protection unit, and advanced emulated EEPROM functionality. The S12XE and S12XS families give customers flexibility from 64K up to 1M flash and packages from 64LQFP to 208MapBGA.1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2Overview of S12XS Family . . . . . . . . . . . . . . . . . . . . . . . 2 3Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33.1P-Flash (Program Flash). . . . . . . . . . . . . . . . . . . . . 33.2D-Flash (Data Flash). . . . . . . . . . . . . . . . . . . . . . . . 43.3RAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 5Port Integration Module (PIM). . . . . . . . . . . . . . . . . . . . . 6 6Part IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 7Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7S12XS Family Compatibility Considerationsby:Lela GarofaloTSPGOverview of S12XS FamilyFor additional information on compatibility between S12XE and S12XS families, please refer to the Freescale application note, “Using the S12XE Family as a Development Platform for the S12XS Family,” (document AN3327).This document describes the differences and key similarities between the S12XS family members that must be considered when moving from a larger umbrella device with more memory and a larger package, to a smaller device with less memory and a smaller package.The topics discussed are:•Memory mapping and paging•Peripherals•Port integration module•Part IDs2Overview of S12XS FamilyThis document is meant to be used in conjunction with the S12XS family data sheet located at. Table1 gives an overview of the parts, available peripherals, and package options for each of the family members.Table1. Family FeaturesDevice Package XGATE CAN SPI SCI TIM PIT A/D PWM I/0S12XS256112 LQFPNotAvailable 1128ch4ch1/168ch9180 QFP1128ch4ch1/88ch59 64 LQFP1128ch4ch1/88ch44S12XS128112 LQFP1128ch4ch1/168ch91 80 QFP1128ch4ch1/88ch59 64 LQFP1128ch4ch1/88ch44S12XS64112 LQFP1128ch4ch1/168ch91 80 QFP1128ch4ch1/88ch59 64 LQFP1128ch4ch1/88ch44Memory3MemoryTable 2 gives an overview of the memory sizes available for the S12XS family. Local and global memory maps are compatible across the family. Out of reset, the family has equivalent maps and default values in the memory map control (MMC) registers. For devices with smaller amounts of memory, those areas unimplemented in the map will cause a reset if accessed.3.1P-Flash (Program Flash)The P-flash memory constitutes the main nonvolatile memory for applications. The P-Flash memory iscompatible for all flash devices in the S12XS family for all memory sizes in terms of functionality for program, erase, security, and protection setup. All family members have a single physical flash block that is equivalent to the defined flash size. Table 3 shows the physical flash block sizes in correlation to the global address.Table 2. Memory Sizes by DeviceDevice Flash R OM RAMData Flash9S12XS256256K — 12K 8K 9S12XS128128K — 8K 8K 9S12XS6464K —4K 4K 3S12XS256 —256K 12K — 3S12XS128—128K 8K — 3S12XS64—64K4K—Table 3. Physical P-Flash BlocksGlobal Address S12XS256S12XS128S12XS640x7C_0000256KB Flash BlockUnimplemented Unimplemented0x7D_FFFF 0x7E_0000128KB Flash BlockReserved0x7E_FFFF 0x7F_000064KB Flash Block 1The 9S12XS64 uses the 9S12XS128 die tested only for 9S12XS64 functionality. Accessing flash between address0x7E_0000 through 0x7E_FFFF does not cause an access error reset of device on a S12XS64 device with part ID $C1C0. The PartID register should be verified for the actual device.0x7F_FFFFMemoryFor all flash devices, programming and erase operations will be equivalent. Programming is done in phrases, or four word increments. Erase operations can be done in sectors or blocks. Simultaneous read while write and read while erase from P-flash is not available because there is only one physical block implemented on the 9S12XS family devices.Protection is compatible for all memory sizes of the S12XS family where implemented areas are equivalent.Security is equivalent for all S12XS family devices. The options/security byte is located at global address 0x7F_FF0F.PPAGEs for local memory maps are compatible across all family members where implemented areas are equivalent. Global memory map maps from higher order address down to a lower order address. Accessing unimplemented P-Flash space will cause an access error. An access error will cause the part to reset.3.2D-Flash (Data Flash)D-Flash will be compatible for all 9S12XS family flash devices where implemented areas are equivalent. 9S12XS256 and 9S12XS128 have an equivalent implemented amount of 8K. ROM devices do notimplement data flash. The global memory map maps from a lower order address to a higher order address.The D-flash can be accessed on the local memory map through the 1K DFLASH window through control of the EPAGE register. The EPAGE register has a default value of 0xFE out of reset. EPAGE 0xFE is unimplemented space on the S12XS family. Therefore, when accessing the D-Flash through the 1KD-Flash window, the EPAGE register must be written to with a valid EPAGE. Accessing unimplemented D-Flash space causes an access error. An access error causes the part to reset. Table 4 shows the valid EPAGEs and corresponding global addresses.Table 4. Data FlashEPAGE Global address 9S12XS2569S12X1289S12XS640x000x10_0000 8KB4KB0x10_3FFF 0x010x10_04000x10_7FF 0x020x10_08000x10_0BFF 0x030x10_0C000x10_0FFF 0x040x10_10000x10_13FF 0x050x10_14000x10_17FF 0x060x10_18000X10_1BFF 0x070x10_1C000x10_1FFFPeripherals3.3RAMRAM is compatible for all S12XS family devices where implemented areas are equivalent. Memory maps map from a higher-order address to lower-order address.The RPAGE register allows the user to page 4KB blocks into the RAM page window on the local memory map from address 0x1000 to 0x1FFF. The RPAGE default register value is 0xFD out of reset for all S12XS devices. Also, for all S12XS devices, addresses 0x2000 to 0x3FFF on the local memory map are fixed RAM pages for RPAGEs 0xFE and 0xFF. For the S12XS256, the default value of 0xFD allows for a linear address map to be accessible on the local map between addresses 0x1000 to 0x3FFF. For the S12XS128 and S12XS64 devices, RPAGE 0xFD is unimplemented space, and fixed page 0xFE (0x2000–3FFF) on the S12XS64 is unimplemented space. Accessing unimplemented space will cause an access error and the device to reset. For the S12XS128 and S12XS64, RPAGEs can be accessed through either the fixed RAM space or a valid RPAGE. Table 5 shows the location of RAM out of reset for the XS family.4PeripheralsAll peripherals are functionally compatible across the S12XS family. To maintain compatibility when developing on a larger memory and/or package option to move to a smaller device, pay careful attention to the pin-out and port routing options. A conclusive summary of the pin-outs for all three package options is available in the S12XS family can be found in the product preview, MC9S12XS256PB located at . Refer to table 6 for a complete summary of port routing options.The timer (TIM) module has eight channels available for all three package options. Channels IOC0, IOC1, and ICO2 have port-routing options (see Table 6). For the 80 QFP and 64 LQFP, if all eight PWM channels are used, then TIM channels IOC5 and IOC7 are not available simultaneously.The 112 LQFP has 16 ATD channels available, and all other package options have eight channels. To maintain compatibility when moving to smaller package options, use ATD channels 0–7 only.The pulse-width modulator (PWM) has eight channels available for all three package options. Channels PWM 4–7 have port routing options (see Table 6). PWM4 and PWM6 channels are available only on the 80 QFP and 64 LQFP if the port routing option is used to route to PT4 and PT6. Therefore, if all eight PWM channels are used, then TIM channels IOC5 and IOC7 are not available simultaneously for the 80 QFP and 64 LQFP.Table 5. RAM Global and Local AddressesGlobal Address Local Address RPAGE S12XS256S12XS128S12XS640x0F_D0000x10000xFD 12Kunimplementedunimplemented0x0F_DFFF 0x1FFF 0x0F_E0000x20000xFE 11Accessible through RP AGE window (0x1000 to 0x1FFF) by writing a valid RP AGE value to the RP AGE register.8K0x0F_EFFF 0x2FFF 0x0F_F0000x30000xFF14K0x0F_FFFF0x3FFFPort Integration Module (PIM)The S12XS family has two Serial Communication Interface (SCI) modules, SCI0 and SCI1 for all three package options. SCI1 has additional port routing options available. Refer to table 6 for port routing options.The Serial Peripheral Interface (SPI) has an additional port routing option (see Table 6).5Port Integration Module (PIM)The pin functions and priorities for all S12XS devices are the same after reset or a power-on reset (POR). Port routing options for PWM channels 4–7 and TIM channels 2–0 are controlled by the Port T Routing register (PTTRR). Likewise, port routing options for SCI1 and SPI0 are controlled by the Module Routingregister (MODRR). Table 6 shows the port routing options.6Part IDsFor the 9S12XS family, the part ID is located in two 8-bit registers: PARTIDH and PARTIDL (addresses 0x001A and 0x001B). The read-only value is a unique part ID for each device revision. Table 7 shows the assigned part ID number and mask-set number for each device.Table 6. Peripheral Port Routing Options 11x denotes reset condition, o denotespossible rerouting under software control.S C I 1S P I 0P W MT I M PM[1:0]o PM[5:2] o PP[2,0]o PP[2:0] o PP[7:4] x PS[3:2]x PS[7:4] x PT[2,0] x PT[7:4]oTable 7. Part IDsDevice Mask Set NumberPart ID MC9S12XS2560M05M $C0C0MC9S12XS1280M04M $C1C0MC9S12XS640M04M 1The 9S12XS64 uses the 9S12XS128 die tested for 9S12XS64 functionality only. An actual 9S12XS64 device may be done at a later time. A productchange notification will be posted in such an event. The PartlD register should be verified for actual device.$C1C0TBD$C2C0Summary 7SummaryThe key differences between the devices in the S12XS family are memory mapping. Although many of the peripherals are compatible, you should focus on the default pin/port-routing aspects of the specific peripherals to enable maximum scalability with anticipated future system needs. Part IDs are specific to each device. The S12XS64 device is a special case; any errata differences should be verified and associated to the corresponding part ID.This document is meant to be used with:•MC9S12XS Family Reference Manual•MC9S12XS Family Product Brief (document MC9S12XS256PB)•S12XCPUV2 Reference Manual (document S12XCPUV2)Document Number: AN3497Rev. 007/2007How to Reach Us:Home Page:Web Support:/support USA/Europe or Locations Not Listed:Freescale Semiconductor, Inc.Technical Information Center, EL5162100 East Elliot Road Tempe, Arizona 85284+1-800-521-6274 or +/supportEurope, Middle East, and Africa:Freescale Halbleiter Deutschland GmbH T echnical Information Center Schatzbogen 781829 Muenchen, Germany +44 1296 380 456 (English)+46 8 52200080 (English)+49 89 92103 559 (German)+33 1 69 35 48 48 (French)/supportJapan:Freescale Semiconductor Japan Ltd.Headquarters ARCO T ower 15F1-8-1, Shimo-Meguro, Meguro-ku,T okyo 153-0064Japan0120 191014 or +81 3 5437 9125support.japan@Asia/Pacific:Freescale Semiconductor Hong Kong Ltd.T echnical Information Center 2 Dai King StreetT ai Po Industrial Estate T ai Po, N.T., Hong Kong +800 2666 8080@For Literature Requests Only:Freescale Semiconductor Literature Distribution Center P .O. Box 5405Denver, Colorado 802171-800-441-2447 or 303-675-2140Fax: 303-675-2150LDCForFreescaleSemiconductor@Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document.Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters that may beprovided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals”, must be validated for each customer application by customer’s technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended orunauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that FreescaleSemiconductor was negligent regarding the design or manufacture of the part. RoHS-compliant and/or Pb-free versions of Freescale products have the functionality and electrical characteristics as their non-RoHS-compliant and/or non-Pb-freecounterparts. For further information, see or contact your Freescale sales representative.For information on Freescale’s Environmental Products program, go to /epp .Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners.© Freescale Semiconductor, Inc. 2007. All rights reserved.。
基于MC9S12XS128单片机的循双线智能小车系统设计
户 占用一个 I P地址 ,进而可以与多个用户共享资源数据。
( 2 )基于标准数据通信协议 的 G P R S 业 务 ,可 以实现 I P传 输数据 实现 网络的互通 。全 双工运作 的 G P R S保证 了系统 的接受和传输功能 , 并且计费是按照具体 网络流量来 收取 。
( 3) 核心层采用 I P技 术 的 G P R S 业 务 ,可 以支 持 多种 网络
4 系统 工作 的原 理
P L C通过读取寄存器 I WO的状态 ,并通过 4 8 5总线将
的互通传输 ,进而可 以实现各种终端的远程传输功能。
3 I 2 与 其他 无 线通 讯 方 式 比较
各种数据通过串 口发送 到 G P R S通信模块 ,P L C每定时 2 0 s
将 现场数据 发送 到 D U T,每黄劲.基 @S o c k e t 技 术的煤矿远程监控 系统
U ] . 工矿 自动 化 ,2 0 0 3 , ( 1 ).
1 0
此外 ,还增加 了功能选择按键 作为智 能车的 作方 式的快
设 计 中,使用 两排 “ 一字型 ”的传感器 ,各带 有四个一对
组网灵活 , 采用专用数据传输通道 , 比较适合于恶劣环境 。
5 结语
本 文设 计 的系统 已在工程得到应用 ,水泵可 以得 到远 程的控 制 , 上位机接受各个参量的数据的能力非常的稳定 ,
缺点是对 于同一频点上 ,同时 只能有 一个设备发送数 据 ,
加上 网络覆 盖面积小 ,容量有 限 ,网络后期的运营成本 相
同时设 置波特率 、数据位 、奇偶校 验位等信息 ,数据通过 4 8 5总线的数据 G P R S网络输出到 G P R S收发软件 ,并再将
S12单片机BDM调试器使用技巧
S12单片机BDM调试器使用技巧摘要:全国大学生“飞思卡尔杯”智能汽车竞赛推荐使用Freescale公司的M C9S12系列单片机为主控芯片;有USB接口的TTBDM调试器是主要软件调试工具。
TTBDM调试器通过USB接口与PC通信,BDM接口与目标CPU通信,实现嵌入式软件的在线调试。
根据往届车模竞赛中参赛者遇到的一些问题和本中心在长期支持国内S12系列单片机用户中积累的经验,总结出BDM调试器的用法和注意事项,提供一些使用技巧,以求对参赛者和S12产品开发工程师有所帮助。
关键词: 9S12单片机;BDM;TTBDM第四届全国大学生“飞思卡尔杯”智能气车竞赛推荐采用最新的MC9S12XS1 28(以下简称XS128)单片机作为主控芯片,替代MC9S12DG128。
XS128是Free scale公司推出的S12系列单片机中的一款增强型16位单片机。
片内资源丰富,接口模块有SPI、SCI、IIC、A/D、PWM等常见模块,在汽车电子应用领域具有广泛用途。
XS128和以往大赛使用的S12DG128系列单片机一样,调试接口都是使用Freescale公司传统的BDM(Background Debug Module)接口。
1 MC9S12XS128单片机介绍(1)CPU:增强型16位HCS12 CPU,片内总线时钟最高40 MHz;(2)片内资源:8 KB RAM、128 KB程序闪存、2 KB数据闪存;(3)串行接口模块:SCI、SPI;(4)脉宽调制模块(PWM)可设置成4路8位或者2路16位,逻辑时钟选择频率宽;(5)1个16路12位精度A/D转换器;(6)控制器局域网模块(CAN);(7)增强型捕捉定时器。
MC9S12XS128单片机有112、80和64引脚3种封装形式。
80-pin封装的单片机没有引出用于扩展方式的端口,仅引出了一个8路A/D接口。
竞赛可使用1 12或80引脚封装器件。
2 BDM接口和使用BDM调试器内部有一个8位的MC9HC08JB16单片机,该单片机有USB接口,可与PC机信息交互。
单片机控制摄像头摄像、显示系统111
单片机控制摄像头摄像、显示系统1111 单片机控制摄像头摄像、显示系统系别尚德光伏学院专业微电子技术班级 0801 学生姓名丁良林学号 100080253 指导教师陆亚青 2011年 4 月无锡科技职业学院毕业设计论文单片机控制摄像头摄像、显示系统 1 单片机控制摄像头摄像、显示系统摘要本项目主要是通过是S12XS128单片机来控制摄像头的正常工作并由该单片机送到电脑上。
其实很简单就是通过单片机来控制摄像头来拍照然后单片机再将拍摄到的图片传输到电脑上显示让人眼能看到所拍摄的画面。
所选的MC9S12XS128 单片机产品满足了用户对设计灵活性和平台兼容性的需求并在一系列汽车电子平台上实现了可升级性、硬件和软件可重用性、以及兼容性。
它为用户削减了成本并缩小了封装尺寸。
该项目在很多领域都有广泛的应用例如大学生智能车制作和监控系统。
例外选的OV7620是一款CMOS摄像头器件是一款彩色CMOS 型图像采集集成芯片提供高性能的单一小体积封装该器件分辨率可以达到640X480传输速率可以达到30帧。
关键词MC9S12XS128单片机OV7620摄像头显示系统无锡科技职业学院毕业设计论文单片机控制摄像头摄像、显示系统 2 abstract Abstractthis project mainly through is S12XS128 single shipcontrolling of the camera normal work and by the single-chip microcomputer to computer. Actually very simple is through the single ship controlling camera to take photos and then again to photograph of single-chip computer images transmitted to display on let the human eye can see the picture taken. Selected MC9S12XS128 microcontroller products meet the user to design flexibility and platform compatibility needs and in a series of automobile electronic platform achieved scalability the hardware and software reusability and compatibility. It for the user cut costs and reduce the encapsulation size. This project in many fields are widely used such as college students intelligent car production and monitoring system. Exception chosen OV7620 is a section CMOS camera device is a new color CMOS type image acquisition integrated chips to supply high-performance single small volume encapsulation this device resolution can achieve 640X480 transmission rate can reach 30 frames. Key wordsMC9S12XS128 microcontroller OV7620 cameras the display system. 无锡科技职业学院毕业设计论文单片机控制摄像头摄像、显示系统 3 目录前言 ................................................................. .................................................................................. 1 第一章系统的结构和功能现象 ................................................................. .................................... 1 11 系统的总体结构 ................................................................. ............................................ 1 1.2功能及现象 ................................................................. ....................................................... 2 第二章飞思卡尔XS128单片机介绍 ..................................................................... ........................ 1 2.1 XS128特性与封装 ................................................................. ........................................... 1 2.2单片机和相关引脚介绍 ..................................................................... ............................... 3 第三章OV7620摄像头 ..................................................................... ...............................................1 3.1 OV7620各模块介绍 ................................................................. ......................................... 1 3.1.2本摄像头模块新增特点 ..................................................................... ....................... 1 第四章单片机的连接与编程 ..................................................................... .................................... 2 4.1XS128最小系统 ..................................................................... ...........................................2 4.2 XS128与OV7620的硬件连接 ................................................................. ......................... 2 4.3 MC9S12XS128最小系统测试程序 ..................................................................... ............... 1 4.4 摄像头摄像及PC显示程序 ..................................................................... ........................ 2 总结 ..................................................................... .............................................................................. 2 致谢 ................................................................. .................................................................................. 1 参考文献 ................................................................. ........................................................................ ..1 附录 ................................................................. ................................................................................ 2 无锡科技职业学院毕业设计论文单片机控制摄像头摄像、显示系统 1 前言我们本次设计主要功能是用MC9S12XS128单片机来控制摄像头OV7620的正常工作并且在电脑上显示接受的图像和数据也就是通过XS128单片机输出摄像头采集到的图像经PC串口在电脑上的上位机软件上显示。
飞思卡尔MC9S12XS128功能模块驱动
用了一年多飞思卡尔MC9S12XS128这款处理器,现在总结下各个功能模块的驱动.//锁相环时钟的初始化总线频率为40MHz(总线时钟为锁相环时钟的一半)//晶振为11.0592MHzvoid PLL_init(void) //PLLCLK=2*OSCCLK*(SYNR+1)/(REFDV+1) { //锁相环时钟= 2*11.0592*(39+1)/(10+1)=80MHz 总线时钟为40MHzREFDV=0x0A;SYNR=0x67; //0110_0111 低6位的值为19,高两位的值为推荐值while(CRGFLG_LOCK != 1);CLKSEL_PLLSEL = 1; //选定锁相环时钟//FCLKDIV=0x0F; //Flash Clock Divide Factor 16M/16=1M}//周期中断定时器的初始化-// //周期中断通道1用于脉冲累加器的定时采样,定时周期为: 10ms= (199+1)*(1999+1)/(40M) (没有使用)//周期中断通道0用于控制激光管的轮流发射,定时周期为: 2000us= (399+1)*(199+1)/(40M)//2011/4/4 15:24 定时时间改为1msvoid PIT_init(void){PITCFLMT_PITE = 0; // 禁止使用PIT模块 PITCFLMT :PIT 控制强制加载微计数器寄存器。
PITCE_PCE0 = 1; // 使能定时器通道0//PITCE_PCE1 = 1; //使能定时器通道1PITMUX = 0; //通道0,和通道1均选择8位微计数器0//修改时间只需要改下面四行PITMTLD0 = 199; //向8位微计数器中加载的值PITLD0 = 199; //向16位计数器中加载的值//PITMTLD1 = 39; //向8位微计数器中加载的值 8位,最大值不要超过255//PITLD1 = 1999; //向16位计数器中加载的值PITINTE |= 0x01; //使能定时器通道0的中断PITCFLMT_PITE = 1;//使能PIT模块}//脉冲累加器的初始化, PT7口外接光电编码器//最新修改: 2011/3/25 16:53void PT7_PulAcc_Init(void){DDRT &= 0x77;//设置PT7,PT3口为输入(硬件上PT7,PT3通过跳线联到了一块)PERT |= 0x80; //使能通道7的上拉电阻PPST &= 0x7f; //电阻设为上拉电阻TCTL4 &= 0x3f; //禁止PT3的输入捕捉功能PACTL = 0x50; //启动脉冲累加计数器,上升沿触发,禁止触发中断和溢出中断,主定时器禁止}//通道1用于控制舵机1 PWM 高电平有效,//通道3用于控制电机1 PWM 低电平有效,这与前两代车高电平有效有区别!!!!!//通道7用于给上排激光管提供PWM信号 PWM高电平有效!!!!!//通道6用于给下排激光管提供PWM信号 PWM高电平有效!!!!!// 2011-03-17 7:56 增加了A端口的使用新增通道6//2011-6-9 23:03 //增加了通道4,5的联合使用,用于控制下排方向舵机 void PWM_init(void){PWME = 0x00;//PWM禁止PWMPRCLK = 0x03; // ClockA=40M/8=5M, Clock B = 40M/1=40M PWMSCLB = 10; // Clock SB= 40/2*10= 2MHz(供电机)PWMSCLA = 5; // SA = Clock A/2*5 = 5M/10 = 500K = SA 用于控制舵机PWMPOL = 0xe2; //1110_0010通道7,通道6与通道1、通道5先输出高电平然后输出低电平,POLx=1先输出高电平后输出低电平; PPOLx=0先输出低电平)PWMCAE = 0x00; // 左对齐输出(CAEx=0为左对齐,反之为中心对齐)//PWMCLK = 0010_1010 (0 1 4 5位控制SA_1;或A_0; 2 3 6 7位控制SB_1 或B_0)//为PWM通道1选择时钟 SA(500KHz),//为PWM通道5选择时钟 SA(500KHz),//为通道3选择时钟 SB(10MHz)//为通道7选择时钟B(40MHz)//为通道6选择时钟B(40MHz)PWMCLK = 0x2A; //0010_1010PWMCTL = 0x70; //0111_0000 CON45=1,把通道4,5联合使用。
基于MC9S12XS128单片机的智能车路径识别探究
21 年 1 01 2月
基 于 MC S2 S 2 9 1X 18单 片 机 的 智 能 车 路径 识别 探 究
哈 焱
(. 1 安徽理工 大学 计 算机科 学与工程学 院, 安徽 淮南 22 0 ; . 埠学院 实验 与设备 管理 中心 , 30 12 蚌 安徽 蚌埠 233 ) 300
摘要 : 文研 究了基于 MC S2 S2 本 9 1X 18单片机的智能车 的路径识别 和优 化方案 , 选用 光电传感 器作为 路径识别 的传感器 , 结 合路 径识别算法和控制算法 对智能车的转 向和速度进行优化 配置 , 介绍 了各种弯道路径并对 转 向控制进 行了分析 , 阐述 了
第2卷 1
第 6期
广 东石 油化 工学 院学报
J un f a g o gUnv ri fP t c e clT c n lg o ra o n d n ies yo er h mia e h ooy l Gu t o
V0 . 1 N 6 12 o.
De 2 1 c. 0l
串口调试 , 具有扩展 口,2 B的 Fa 存储器 ,0 18K lh s 4 M z H 的增强 C U 可进行二次开发 , P, 兼容性较高, 监 图1 智能车系 统结构
控 程序 功 能强 大 , 提 供 各 种 基 本 的 开 发 和 调 试 功 能 如 程 序 的 下 载 和 运 行 、 点 设 置 、 存 显 示 等 。 可 断 内 MC S2 S2 9 1X 18具有 增强 型捕 捉定 时 器 、 先 中断 定时 器 、/01 位 模数 转换 器 、 优 81/2 8位脉 冲宽 度调制 (WM) P ,
自主行 使 。
收稿 日期 :0 1 0 7 修回 日期 :0 1 1 5 2 1 —1 —2 ; 2 1 —1 —0
基于MC9S1 2XS1 28单片机智能寻迹小车的设计
基于MC9S1 2XS1 28单片机智能寻迹小车的设计摘要:本文给出了智能小车寻迹系统的软硬件方案设计和开发流程。
采用飞思卡尔MC9S12XS128单片机作为智能小车控制芯片,设计了电源、电机驱动、激光传感器以及测速等模块,小车的速度、转向控制采用PID控制方法,测试结果表明,小车能够平稳实现寻迹功能。
关键词:智能寻迹电机驱动激光传感器PID控制A Design of Intelligent Tracing Car Based on MC9S12XS128Abstract:This paper describes a design of hardware and software of the intelligence tracking car. The system uses Freescale MC9S12XS128 MCU as the control unit. Besides, a series of modules are designed, such as the power circuit, motor driver circuit, laser sensors and speed detecting modules. We use PID control method to control the speed and direction which helps realize intelligence tracking steadily.Key words:intelligence tracking motor driver laser sensor PID control该文以飞思卡尔杯智能车大赛为研究背景,研究了智能寻迹小车的软硬件方案设计和开发流程。
硬件电路方面采用飞思卡尔MC9S12XS128作为核心处理器,通过对比不同设计方案的性能,给出了智能小车电源、电机驱动、光电传感器以及测速等模块的设计方案并加以实现。
基于Labview的Bootloader上位机实现
基于Labview的Bootloader上位机实现作者:田洪杰孔微来源:《理论与创新》2020年第19期【摘要】Labview在测控领域应用广泛,其图形化的编程方式较传统的文本编程方式入门难度更低。
本文使用Labview编写上位机实现了对S19文件的解析、数据的收发,并结合下位机底层Bootloader程序实现了对控制器程序的刷写。
【关键词】虚拟仪器;Labview;Bootloader1.技术背景Labview是美国NI公司推出的一款图形化的编程环境,不同于传统的文本编程环境,Labview通过拖拽连线的方式进行编程,软件内置了大量的功能组件,工程师可以通过对这些组件的组合快速的实现所需的软件功能。
在使用Labview编程时,后端功能逻辑可以与前端界面同步开发,大大提高了编程效率,在SpaceX火箭的地面测控系统中就使用了Labview来编写GUI界面用于发射和控制。
本文使用Labview开发了一款车载控制器的Bootloader上位机系统,并实现了对MC9S12XS128控制器的程序刷写,以此来探索Labview在控制器测试开发中的应用。
2.总体设计Bootloader 上位机主要功能是将编译完成的程序数据刷写到控制器的指定内存区域,实现对控制器程序的更新。
上位机读取程序文件,并将文件解析成数据和对应的刷写地址,通过通用接口将这些指令发送给控制器,控制器的底层Bootloader服务程序在芯片级实现数据的更改。
软件后台总体分为S19文件解析、USBCAN协议转换、数据刷写等几个功能块。
3.S19 文件解析S19文件是飞思卡尔公司推出的一种数据存储格式,文件以文本格式存储了编译后的数据和数据存放地址。
S19文件在每一行数据(又称记录)的起始都用标明了本行的数据类型。
在上位机书解析文件时,关心以S1开头的行即可。
以下面的行为例:S105FF7AC019A8“S1“表明本条记录存储的地址值长度为2字节,”05“表示数据长度,”FF7A“为数据起始地址,”C019“为从起始地址开始需要写入存储区的数据,”A8“为校验位。
基于飞思卡尔MC9S12XS128芯片的智能车刹车系统的研究
b r e a k ;
n t = 2 ; e a s e r a mp wa y : s p e e d wa
图 5 非理想刹车系统波形图
i f ( s p e e d _ e r r o r [ 1 ] < =2&&s p e e d _ 一 e r o r [ 1 j > = 一 2 )
r e t u r n;
此时也会对赛车的平稳运行 产生一定 的影 响, 根据软件算 法的描述 , 即每个 调节周期对 2路 P WM因素 , 故应在每个调节周
2 0 第 1 4年 3期 2月
江 苏科技信息 ・ 研究 与交流
N o . 3
Fe b r u a r y, 2 01 4
达到则停 止调节 ,若没有则 通过 P I D控 制算 法改变调节输 出
量 即反 向 P WM波 P P 3的 占空 比 z %继续调节 ,直 至通 过编码
稳性 ) 变化 , 随着每一调 节周期 的反馈 比较进 而对变化量参 数 改变后再进行控制输出 , 直 至赛车在进入下一赛道类型前平 稳 运行在预期速度 , 从 而达 到赛车在变速的过程 中依然快 速且平
稳运行的 目的 。
3 核 心 程序
Vo i d i me r r u p t s t o p
{
c a s e s t as h t : s p e e d wa n t = 5;
_
通过引入刹车系统实 现赛 车在高速运行情况 下的有效制
动, 减少 了“ 实 际线性变速 区” 的范 围以及赛车因速度过快却无
法控制而产生 的车体晃动 、 甩尾 、 漂移 等不稳定情况 的出现 , 从 而增加 了赛车能 以更快 的速度平稳跑完赛道 的可能性 , 也为 以 更快 速度且平稳 的完成 比赛提供 了更多 的可能 。
基于mc9s12xs128的花卉追光系统设计
块 , 行 模数 转 换 , 而得 到 四 个方 向光 强 进 从 度 的 数 字 信 号 , 便 于 更 好 的 进 行 信 息 处 以 理 , 后 通过 软 件 编程 控 制 步进 电机 , 行 然 进
此各种资料例程非常丰富 , 编程 操 作 也 十 分 简单 直接 , 于操 作 , 般 是 初 学者 的 首 易 一 自己拓 展AD模 块 ,
一
_ 进机 . 电 1 步
片机编 程要 复杂一 点 , 是 比起 Co tx 但 re M3 的编 程 , 容 易 得 多 , 部 资 源 丰 富 , 能 要 内 功 和 C re t 仿 。 o tx H 以mc s 2 s 2 为例 , 1 路 9lx l8 有 6
吕
1 I . 。 。
步 进 电 机 正转 9 0
步 进 电 机 正 转 I0 8
AD转换 通 道 , 转换 精 度 8 到 1 位 可 选 。 位 2 综 上 所 述 , 于本 系统 需 要 多路 AD转 由
换 , 格 低 廉 ,另 外 便 于 使 用 ,故 采 用 价
F e sae 列 的 mc s 2 s 2 作 为 控 制 器 。 r ec l系 9lx 18
用 使 用 最 方 便 的 光 敏 电 阻 最 为传 感 器 。 步进 电机 有很 多 , 几元 到几 百元 , 从
( 下转 2 页 ) 0
图 3 步 进 电 机 控 制 原 理 图
步 进 电 机 控 制
i 1j - , =l i 2, - - J 2
i ,= =l j 2 i 2j 3 - ,- i 3, = - j4
一
花卉 追 光 或 自由旋 转 。
并且 速 度 和其 他 功 能 都要 比 5 单 片机 强 很 l
关于Codewarrior中的prm文件[1]
中电网.深山老林关于Codewarrior 中的 .prm 文件 要讨论单片机的地址映射,就必须要接触.prm文件,本篇的讨论基于 Codewarrior5.0编译器,单片机采用MC9S12XS128。
通过项目模板建立的新项目中都有一个名字为“project.prm”的文件,位于Project Settings->LinkerFiles文件夹下。
一个标准的基于XS128的.prm文件起始内容如下: .prm文件范例:/*ThisisalinkerparameterfilefortheMC9S12XS128*/parameters.*/NAMESENDSEGMENTSlogical'*//*Registerspace*//*TO0x07FF;intentionallynot defined*/RAM=READ_WRITE DATA_NEAR TO0x3FFF;ROM_4000=READ_ONLY DATA_NEAR IBCC_NEAR TO0x7FFF;ROM_C000=READ_ONLY DATA_NEAR IBCC_NEAR TO0xFEFF;/*VECTORS=READ_ONLY TO0xFFFF;intentionallynot//OSVECTORS=READ_ONLY TO0xFFFF;/*OSEKinterrupt/*pagedEEPROM TO0x0BFF;addressedthrough EPAGE*/EEPROM_00=READ_ONLY DATA_FAR IBCC_FAR0x000800TO0x000BFF;中电网.深山老林EEPROM_01=READ_ONLY DATA_FAR IBCC_FAR0x010800TO0x010BFF;EEPROM_02=READ_ONLY DATA_FAR IBCC_FAR0x020800TO0x020BFF;EEPROM_03=READ_ONLY DATA_FAR IBCC_FAR0x030800TO0x030BFF;EEPROM_04=READ_ONLY DATA_FAR IBCC_FAR0x040800TO0x040BFF;EEPROM_05=READ_ONLY DATA_FAR IBCC_FAR0x050800TO0x050BFF;EEPROM_06=READ_ONLY DATA_FAR IBCC_FAR0x060800TO0x060BFF;EEPROM_07=READ_ONLY DATA_FAR IBCC_FAR0x070800TO0x070BFF;TO0x1FFF;addressedthrough RPAGE*//*RAM_FE=READ_WRITE0xFE1000TO0xFE1FFF;intentionallynot/*=READ_WRITE0xFF1000TO0xFF1FFF;intentionallynot/*pagedFLASH:TO0xBFFF;addressedthrough PPAGE*/PAGE_F8=READ_ONLY DATA_FAR IBCC_FAR0xF88000TO0xF8BFFF;PAGE_F9=DATA_FAR IBCC_FAR0xF98000TO0xF9BFFF;PAGE_FA=READ_ONLY DATA_FAR IBCC_FAR0xFA8000TO0xFABFFF;PAGE_FB=READ_ONLY DATA_FAR IBCC_FAR0xFB8000TO0xFBBFFF;PAGE_FC=DATA_FAR IBCC_FAR0xFC8000TO0xFCBFFF;/*PAGE_FD=READ_ONLY0xFD8000TO0xFDBFFF;intentionallynotPAGE_FE=READ_ONLY DATA_FAR IBCC_FAR0xFE8000TO0xFEBFFF;/*PAGE_FF=READ_ONLY0xFF8000TO0xFFBFFF;intentionallynot ENDPLACEMENT_PRESTART,STARTUP,ROM_VAR,/*constantvariables*/STRINGS,/*stringliterals*/VIRTUAL_TABLE_SEGMENT,/*eventuallyOSEKcode*/DEFAULT_ROM,NON_BANKED,COPY/*copydowninformation:howtoinitializevariables*/option:-OnB=b*/INTO ROM_C000/*,ROM_4000*/;OTHER_ROM INTO//.stackstart,SSTACK,//.stackend,PAGED_RAM,DEFAULT_RAMINTO RAM;DISTRIBUTE DISTRIBUTE_INTOROM_4000,PAGE_FE,PAGE_FC,PAGE_FB,PAGE_FA,PAGE_F9,PAGE_F8;CONST_DISTRIBUTE DISTRIBUTE_INTOROM_4000,PAGE_FE,PAGE_FC,PAGE_FB,PAGE_FA,PAGE_F9,PAGE_F8;DATA_DISTRIBUTE DISTRIBUTE_INTORAM;INTO OSVECTORS;/*OSEKvectortable*/ENDENTRIES/*keepthefollowingunreferencedvariables*/ENDSTACKSIZE0x100VECTOR 0 _Startup//VECTOR0Entry//INITEntry1 .prm 文件组成结构 按所含的信息的不同.prm文件有六个组成部分构成,这里仅讨论和内存空间映射关系紧密的三个部分,其他的不做讨论。
