Kinetis K系列Flexmemory模拟EEPROM_exmaple
关于EEPROM的应用总结

关于EEPROM的应用总结关于EEPROM的应用总结当在程序运行的过程中你希望修改某个变量并且此变量的值在掉电以后不丢失,那么你就可以采用将变量数据写入EEPROM的方式来实现。
什么是EEPROM,即Electrically Erasable ProgrammableRead_Only Memory首先它是一种存储器,并且可以通过高电压来进行反复擦写的存储器。
具有掉电数据不丢失的特点。
比如常用的24C系列,93C系列的器件。
一般这种器件采用I2C的方式与单片机进行通讯,对于这种通讯方式及器件的应用另作总结。
这里主要总结一下,STC12C5204AD芯片内部包含的EEPROM的应用方法。
STC12C5201AD系列单片机内部集成了EEPROM是与程序空间分开的,利用ISP/IAP技术可将内部data flash当EEPROM,擦写10万次以上。
EEPROM可分为若干个扇区,每个扇区包含512字节。
使用时建议同一次修改的数据放在同一个扇区,不是同一次修改的数据放在不同的扇区,不一定要用满。
数据存储器的擦除操作是按扇区进行的。
在程序中可对EEPROM进行字节读写/字节编程/扇区擦除操作。
在工作电压Vcc偏低时,建议不要进行EEPROM/IAP操作。
以免发生数据错误。
应用的步骤1、声明与EEPROM相关的寄存器2、编写EEPROM初始化函数3、编写字节擦除函数4、编写字节编程函数5、编写字节读取函数6、在需要读取EEPROM字节内容时直接调用字节读取函数即可7、在需要进行写EEPROM字节时,先调用字节擦除函数,将字节内容擦除成FFH后,在调用字节编程函数,将数据写入到EEPROM的地址单元中。
与EEPROM应用相关的寄存器符号描述地位地址及符号复位值址IAP_DATA ISP/IAP flash dataregisterC2H11111111BIAP_AD DRH ISP/IAP flashaddress highC3H00000000BIAP_AD DRL ISP/IAP flashaddress lowC4HIAP_CMDISP/IAP flashcommand registerC5HMS1MSIAP_TRIGISP/IAP flashcommand triggerC6HxxxxxxxxxBIAP_CO NTR ISP/IAP controlregisterC7HIAPENSWBS SWRSTCMD_FAILWT2WT1WT0000X000BPCON Power control87H SOMDSMOD0LVDFPOFGF1GFPDIDL00110000B1、IAP_DATA:ISP/IAP数据寄存器ISP/IAP操作时的数据寄存器。
flexnvm模拟eeprom实现原理

flexnvm模拟eeprom实现原理FlexNVM模拟EEPROM的实现原理主要基于Flash内存的非易失性存储特性。
以下是其实现原理的详细解释:1. 存储器阵列配置:FlexNVM使用一个二维的存储器阵列来模拟EEPROM的存储结构。
这个阵列由许多存储单元组成,每个存储单元可以存储一个字节或多个字节的数据。
阵列的大小可以根据需要进行配置,以满足不同EEPROM容量的需求。
2. 写入数据:当需要将数据写入EEPROM时,FlexNVM通过编程指令将数据写入存储器阵列的相应位置。
在写入数据时,FlexNVM会根据数据的大小和存储单元的大小选择合适的存储单元,并将数据写入其中。
写入操作包括将数据编码并写入Flash内存的过程。
3. 读取数据:当需要从EEPROM中读取数据时,FlexNVM根据读取指令从相应的存储单元中读取数据。
在读取数据时,FlexNVM会根据数据的类型和存储单元的大小选择合适的存储单元,并将数据读取出来。
读取操作包括解码和读取Flash内存中的数据的过程。
4. 擦除数据:在EEPROM中,数据的擦除是通过擦除指令完成的。
同样地,FlexNVM也通过擦除指令来擦除存储器阵列中的数据。
在擦除数据时,FlexNVM 会选择相应的存储单元,并将其中的数据擦除为特定的初始值(通常是0xFF)。
擦除操作包括将Flash内存中的数据清空的过程。
5. 数据保持和可靠性:由于Flash内存具有保持数据的特性,即使在电源关闭的情况下,FlexNVM也能保持其存储的数据。
此外,FlexNVM还采用了错误检测和纠正(EDC/ECC)技术来确保数据的可靠性和完整性。
6. 寿命管理:FlexNVM还具有寿命管理功能,可以跟踪和管理Flash内存的写入和擦除次数。
通过寿命管理,FlexNVM可以确保Flash内存的可靠性和持久性,避免过度使用或滥用导致存储器损坏或性能下降。
通过以上步骤,FlexNVM可以模拟EEPROM的存储结构,并实现数据的写入、读取和擦除操作。
Kinets K60 SDHC模块对SD设备操作方法详解

Kinetis K60 SDHC模块对SD设备操作方法详解中国科学技术大学电子科学与技术系2011级游绩榕2013年1月6日【关键词】本文简单介绍了SD设备,并通过例程来详细解释如何使用K60的SDHC模块对SD卡进行读写操作。
1 适用范围本文所处的环境为:win7-32位系统,IAR System 6.4,P&E公司osjtag调试器,龙丘MK60DN512ZVLL10P100。
单片机主频200M,SD卡为金士顿512M卡1张,金士顿4G卡(Class-4)1张。
本文所实现的功能为:使用SDHC模式,基于SD2.0协议对SD卡和SDHC卡进行单扇区进行不连续的读操作和写操作,SD设备波特率为25M,扇区大小为512B,连续写操作最小间隔为1.5ms(最短),2ms(稳定)。
读写一次的时间约为50~100us。
SD家族介绍SD设备分为许多类型。
SD卡(Secure Digital Memory Card)是一种基于半导体闪存工艺的存储卡, 1999年,由日本松下、东芝及美国SanDisk公司共同研制完成。
2000年,这几家公司发起成立了SD协会(Secure Digital Association简称SDA),阵容强大,吸引了大量厂商参加。
其中包括IBM,Microsoft,Motorola,NEC、Samsung等。
在这些领导厂商的推动下,SD卡已成为目前消费数码设备中应用最广泛的一种存储卡。
SD卡最初是从MMC(Multimedia Card)卡基础上发展起来的,可以与MMC卡实现兼容;但SD卡数据传输速率更快,此外,还特别增加了CPRM(Content protection for Recordable Media)功能,用于卡内数据的授权访问,实现内容保护。
SD卡尺寸为32mm x 24mm x 2.1mm,相当于邮票大小,这样尺寸的存储卡用在数码相机、DV机中还算合适,但在记录不断被刷新的轻薄手机面前,SD卡显得过分“庞大”。
K60-02节

K60系列的存储器空间地址映像(一)
地址范围 0x0000_0000~0x0FFF_FFFF 0x1000_0000~0x13FF_FFFF 大小 实际的物理对象 256MB 可编程flash和只读数据(包括一开始1024字节的异常中 断向量) 64MB 对MK60N256VLQ100芯片:未使用 对MK60X256VLQ100芯片:FlexNVM 对MK60N512VLQ100芯片:未使用 对MK60N256VMD100芯片:未使用 对MK60X256VLQ100芯片:FlexNVM 对MK60N512VMD100芯片:未使用
256
512 512
256
256 512
—
4 —
64
64 128
100
100 100
2.4 K60系列微控制器的存储器映像与编程结构
2.4.2 K60系列存储器映像 ARM Cortex-M4为32位处理器内核。内部的数据是32位 的,寄存器是32位的,存储器接口也是32位的。
CPU频 率 (MHz) 100 100 100 120 150 120 150 闪存 (KB) 256 512 256 512 512 1024 1024 FlexNV M (KB) — — 256 512 512 — — SRAM (KB) 64 128 64 128 128 128 128 FlexRA M (KB) — — 4 16 16 — — 100 LQFP 14× 14 + + + — — — — 104 BGA 8× 8 + + + — — — — 144 LQFP 20× 20 + + + + + + + 144 BGA 13× 13 + + + + + + + 196 BGA 15× 15 — — — + + + + 256 BGA 17× 17 — — — + + + +
手把手学会官方例程四Kinetis KL25 低功耗模式-中篇

飞思卡尔中文论坛支持小组所在地:/bbs/forum_1280.htmlLow Power例程指南(中篇)运行平台✓TWR-KL25Z48M✓TWR-SER✓FRDM-KL25Z✓Keil MDK/IAR ARM IDELow Power Mode简介飞思卡尔Kinetis系列MCU基于90纳米TFS技术,使得MCU在低功耗模式下,拥有良好的性能和功耗表现,尽可能的延长电池寿命,基于ARM Cortex M0+的Kinetis L系列MCU更是凭借其卓越的低功耗表现,被评为业内最低功耗的MCU。
飞思卡尔Kinetis系列MCU有别于传统ARM核MCU只有Run、Wait、Stop三种功耗模式,其功耗模式最多可达11种之多(如图1所示),可满足客户对MCU各种低功耗的配置要求,同时支持多种唤醒方式,方便客户使用。
各模式之间的转换参照图2。
图 1 功耗模式分类图 2 功耗模式状态转换图代码说明(Keil MDK)及测试结果Low Power Mode函数—LowPowerModes_test()代码说明1,C ASE 0:进入VLLS0且禁止POR(1)代码说明(2)测试结果首先在复位状态下,输入一个值,用于选择芯片运行模式。
这里选择0,然后键盘再任意输入一个值,进入到禁止POR的VLLS0模式下,运行结果见下图:DATASHEET值与测试结果的对比:2,CASE 1:进入VLLS0且使能POR(1)代码说明(2)测试结果复位后,键盘输入字符1,选择带POR的VLLS0模式,然后再输入一个任意值,进入该模式。
DATASHEET值与测试结果的对比3,C ASE 2:进入VLLS1(1)代码说明(2)测试结果复位后,键盘输入字符2,选择VLLS1模式,然后再输入一个任意值,进入该模式。
DATASHEET值与测试结果的对比4,C ASE 3:进入LLS模式且每秒被LPTMR中断唤醒(1)代码说明LPTMR中断函数说明:(2)测试结果—case3复位后,键盘输入字符3,选择LLS模式,并使用内部模块LPTMR中断唤醒,然后再输入一个任意值,进入该模式。
Kinetis全系列选型手册-14

SPI
I2C
I2S
CA
线
口 接口 T
N
USB QTG(1)
2 41
2 51
2 51
2 41
2 51
2 51
18/16/2
3 5211
20/16/4
4 5211
32/32/6
5 6211
18/16/2
3 5211
20/16/4
4 5211
21/16/5
5 6211
32/32/6
5 6211
18/16/2
4 521
FS
5 6 3 1 1 FS
6 6 3 1 1 FS
32/32/6 8位 32/32/6 8位 32/32/6 8位
6 6 3 1 1 FS 5 6 3 1 1 FS 6 6 3 1 1 FS
32/32/6 8位
6 6 3 1 1 FS
以太网
定时器
模拟 能
电机控 带正 AD ADC ADC
22√
66
32/32/6
4 621
FS¢
2*8 2*2 2 4 38
22√
81
18/16/2
3 5 3 1 1 FS
2*8 2*2 2 2 22
13√
40(38)
20/16/2 4位
4 5 3 1 1 FS
2*8 2*2 2 3 27
13√
52(52)
21/16/5 4位
5 6 3 1 1 FS
2*8 2*2 2 5 33
USB QTG(1)
FS¢ FS¢ FS¢ FS¢ FS¢ FS¢ FS¢ FS¢
以太网
定时器
模拟 能
恩智浦半导体Kinetis K22系列MCU引导加载程序用户指南说明书

00000005981LF-000EOS Power 1-855-837-4225Give us a callInternational: 1-555-555-55551-415-281-38661IntroductionThis document describes how to use the Kinetis bootloader toload a user application on a Kinetis K22 series MCU.2Overview This guide describes the steps required to use the Freescale-provided Kinetis bootloader utilities to both load the Kinetisbootloader image and use the bootloader to update the userapplication section of flash. Upon reset, the bootloader detectsthe presence of the user application and launches it. Thebootloader also provides a means to suppress the applicationlaunch and remain in the bootloader command processor inorder to refresh the user application. This full-circleenvironment enables application developers to easily installnew applications onto Kinetis devices, and providesmanufacturers a way to update Kinetis devices in the fieldwithout the need for a debugger.2.1Kinetis bootloaderUser's Guide Rev 0, 12/2014Demo Application User's Guide for the FRDM-K22F and TWR-K22F120M Freescale Platforms © 2014 Freescale Semiconductor, Inc.Contents1Introduction................................................................12Overview.. (13)Hardware configuration (24)Kinetis bootloader application...................................45The host utility application. (7)6Windows GUI updater application (8)7Appendix A Kinetis flash-residentbootloader operation (11)8Revision History (14)The Kinetis bootloader serves as the standard bootloader for all Kinetis devices. It provides a standard interface to the device via all of the available peripherals supported on a given Freescale Kinetis device. The Kinetis bootloader interface comes in several forms, ranging from ROM, serial flashloader, or a customized flash-resident bootloader. All future Kinetis devices will arrive with a ROM containing the Kinetis bootloader, while others will arrive pre-programmed from the factory with a one-time-use serial flashloader. For a customized interface, customers can leverage the Kinetis bootloader source code to create a unique flash-resident bootloader that is both compatible with tools that understand the bootloader interface, and are capable of supporting application-specific features. Freescale provides utilities to demonstrate how to interface with the bootloader.2.2Host utilityThe blhost.exe utility is a cross-platform host program used to interface with devices running the Kinetis bootloader. It can list and request execution of all of the commands supported by a given Kinetis device running the bootloader.2.3led_demo user applicationThe led_demo_FRDM-K22F*.bin and led_demo_TWR-K22F120M*.bin programs are example demo firmware applications used to demonstrate how the Kinetis Bootloader can load and launch user applications.2.4Host updaterThe KinetisUpdater.exe host application is a Windows® GUI program used to update the user application image on the device running the Kinetis bootloader firmware application.2.5Toolchain requirementFirmware projects:•IAR Embedded Workbench for ARM version 7.20 (or later)Host projects:•Microsoft® Visual Studio® Express 2013 for Windows Desktop•Microsoft® .NET Framework 4.5 (included in Windows 8)•Microsoft® Visual C++ Redistributable for Visual Studio 2013 (vcredist_x86.exe)•Python v2.7 ( )3Hardware configurationThis section describes how to set up the hardware in order to run the Kinetis bootloader example.Demo Application User's Guide for the FRDM-K22F and TWR-K22F120M Freescale Platforms, Rev 0,12/20143.1FRDM-K22FThe bootloader example application assumes that all platform jumpers are set to their default positions.Figure 1. Front side of FRDM-K22F platform3.2TWR-K22F120MThe bootloader example application assumes that all module jumpers are set to their default positions.Demo Application User's Guide for the FRDM-K22F and TWR-K22F120M Freescale Platforms, Rev 0,12/2014Figure 2. Front side of TWR-K22F120M module4Kinetis bootloader applicationThis section describes how to connect the platform to the computer and download the pre-built Kinetis bootloader application.4.1Connect the Freedom platformThe following section assumes the board is set up with the default factory configurations. For more information, visit /FRDM-K22F .For Windows PCs, install the mbed serial port driver in order to communicate with the Kinetis device over a serial port.1.Download and install the latest mbed Windows serial port driver from /handbook/Windows-serial-configuration .2.Connect the OpenSDA USB connector, J5 for the FRDM-K22F board, to the USB port on a PC.3.Install the mbed serial port driver.Demo Application User's Guide for the FRDM-K22F and TWR-K22F120M Freescale Platforms, Rev 0,12/2014Figure 3. mbed serial port in Windows Device ManagerFigure 4. Driver software installation4.1.1Install the Kinetis bootloader onto the Freedom PlatformTo install the bootloader application, drag or copy and paste the freedom_bootloader.bin file from <install_dir>/targets/ MK22F51212/binaries onto the MBED mass storage device.Demo Application User's Guide for the FRDM-K22F and TWR-K22F120M Freescale Platforms, Rev 0,12/2014Figure 5. Install the Kinetis bootloader on the FRDM board4.2Connect the Tower moduleThe following section assumes the board is set up with the default factory configurations. For more information, visit /TWR-K22F120M .For Windows PCs, install the P&E Micro OpenSDA drivers in order to communicate with the Kinetis device over a serial port.1.Connect the module to the USB port on a PC using the module's debug USB connector.2.Download the driver package from the P&E Micro website ( /opensda/ ) and run the installer.3.After the installer finishes, plug in the module and open the Windows Device Manager to show the COM port numberassigned to the virtual serial port.Figure 6. OpenSDA virtual comport in Windows Device ManagerDemo Application User's Guide for the FRDM-K22F and TWR-K22F120M Freescale Platforms, Rev 0,12/2014Figure 7. Driver software installation4.2.1Install the Kinetis bootloader onto the Tower ModuleTo install the bootloader application, drag the tower_bootloader.srec file from <install_dir>/targets/MK22F51212/binariesonto the TWR-K22F120 mass storage device.Figure 8. Install the Kinetis bootloader on the TWR board5The host utility applicationThis section describes simple use of the blhost host utility program to demonstrate communication with the Kinetisbootloader.Demo Application User's Guide for the FRDM-K22F and TWR-K22F120M Freescale Platforms, Rev 0,12/2014•Open a command prompt in the directory containing blhost. For Windows, it is <install_dir>/bin/win.•Type blhost --help to see the complete usage of the blhost utility.For this exercise, verify the Kinetis device is running the bootloader firmware application.•Press the "Reset" button on the platform.•Note what the COM port that the platform is connected to. Refer to step 3 of section 4.1. For this guide, the device is connected to COM23.•Type blhost -p COM23 -- get-property 1 to get the bootloader version from the Kinetis bootloader.•Something similar to the screen shot below indicates that blhost.exe is successfully communicating with the Kinetisbootloader on the platform.Figure 9. Host communication with Kinetis bootloader6Windows GUI updater applicationThis section describes how to use the Windows GUI updater application, KinetisUpdater.exe, to install an example user application onto the platform.6.1Installing the user applicationThe FRDM-K22F platform is used in this example. Similar steps can be used for the TWR-K22F120M module.1.Click the "Reset" button on the platform.2.Navigate Windows Explorer to the <install_dir>/bin/win/KinetisUpdater directory.3.Double-click the KinetisUpdater.exe file to launch the app.NOTEIf the application fails to launch, check that the .NET Framework 4.5 and theVisual C++ Redistributable 2013 are installed as noted in Toolchain requirements.4.Start at the orange home screen. Click "Select Device".•The blue device configuration page will show.•Select the COM23 device from the drop-down box.•Click "Home" to return to the home screen.Demo Application User's Guide for the FRDM-K22F and TWR-K22F120M Freescale Platforms, Rev 0,12/2014Figure 10. Select the COM port5.Click "Select Image".•The blue image configuration page will show.•Select the led_demo_FRDM-K22F_a000.bin application image from the <install_dir>/apps/led_demo/binaries directory using the "Browse" button.•Set the base address to 0xA000.•Click "Home" to return to the home screen.Figure 11. Browse for the user applicationDemo Application User's Guide for the FRDM-K22F and TWR-K22F120M Freescale Platforms, Rev 0,12/20146.Figure 12. Set base address for application file7.The "Update" button should now be enabled. Click "Update".•The blue update page will now be displayed.•Click the "Update" button to write the application image to the device flash.•Click "Home" to return to the home screen.Figure 13. Perform the update8.Click the "Exit" button.9.At this point, the led(s) on the target board should be noticably blinking indicating that the Kinetis Bootloadersuccessfully installed the led_demo user application.6.2Returning to Flash-resident bootloaderTo return to the Kinetis bootloader interface, simply hold SW3 and press and release the "Reset" button on the target board.When the device resets, the Kinetis bootloader will detect the press on SW3 and not jump to the user application. Verify youare in bootloader mode by again running the blhost.exe tool as done earlier.Figure 14. Back to the Kinetis bootloader interfacePressing the "Reset" button alone will allow the Kinetis Bootloader to again launch the led_demo application.7Appendix A Kinetis flash-resident bootloader operationThis section describes the linkage between the Kinetis flash-resident bootloader and the user application. The demonstration described above illustrates a fairly simple collaboration between the Kinetis bootloader and the led_demo application. The considerations are:•The flash-resident bootloader is located in flash at address 0.•The user application is located in flash above the bootloader at BL_APP_VECTOR_TABLE_ADDRESS as defined in <install_dir>/apps/targets/<mcu>/src/bootloader_config.h•The vector table for the User Application must be placed at the beginning of the application image.•The Bootloader Configuration Area (BCA) must be placed at 0x3C0 from the beginning of the image.7.1Memory map overviewFigure 15. Device memory mapFigure 16. User application vector table and Bootloader Configuration Area (BCA)7.2User application vector tableThe Kinetis bootloader checks BL_APP_VECTOR_TABLE_ADDRESS+0 for the User Application stack pointer andBL_APP_VECTOR_TABLE_ADDRESS+4 for the User Application entry point. Initially, this area is expected to be erased(0xFF) and the bootloader remains in its command interface.Once a User Application is installed to BL_APP_VECTOR_TABLE_ADDRESS, the bootloader jumps to the application after a period specified by peripheralDetectionTimeoutMs in the Bootloader Configuration Area (BCA).7.3Bootloader Configuration Area (BCA)The Bootloader Configuration Area is located at offset 0x3C0 from the beginning of the User Application image. This information is read by the Kinetis bootloader early during the bootloader initialization in order to set up clocks and gather other information relevant to detecting active peripherals. If the first four bytes of the BCA are not ‘kcfg’, the bootloader does not use any information from the BCA on flash.For this tutorial, the led_demo application set the tag field to ‘kcfg’ and the peripheralDetectionTimeoutMs to 500 sothat the bootloader would only wait 500 milliseconds before launching the led_demo application instead of the default 5second wait period.8Revision HistoryThis table summarizes revisions to this document.How to Reach Us: Home Page: Web Support: /support Information in this document is provided solely to enable system and software implementers to use Freescale products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits based on the information in this document. Freescale reserves the right to make changes without further notice to any products herein.Freescale reserves the right to make changes without further notice to any products herein. Freescale makes no warranty, representation, or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale 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 be provided in Freescale 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 does not convey any license under its patent rights nor the rights of others. Freescale sells products pursuant to standard terms and conditions of sale, which can be found at the following address: / SalesTermsandConditions.Freescale, the Freescale logo, and Kinetis are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. Tower is a trademark of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. ARM and Cortex are registered trademarks of ARM Limited (or its subsidiaries) in the EU and/or elsewhere. mbed is a trademark of ARM Limited (or its subsidiaries) in the EU and/or elsewhere. All rights reserved.© 2014 Freescale Semiconductor, Inc.Document Number K22BTLDRDEMOUGRevision 0, 12/2014。
KinetisK和L系列MCU的生产用Flash编程最佳做法

1简介本应用说明描述对Kinetis K 系列和L 系列器件进行生产用flash 编程的建议步骤。
用户可以选择不同的物理接口,与MCU 之间通信对flash 编程,还有多条命令可用于修改flash 内容。
本应用说明将讨论不同的物理接口、flash 命令,并提供推荐的操作顺序,以尽量减少flash 编程过程中出现的问题,并缩短flash 编程时间。
本说明适用于开发生产用flash 编程硬件、生产用flash 编程软件或用于支持flash 编程的调试器接口的任何用户。
虽然本文档中的某些信息可能对软件控制的现场固件更新有参考价值,但本文档并未明确阐述此主题。
2Kinetis flash 类型Kinetis K 和L 系列器件均使用Freescale 薄膜存储器(TFS)flash ;但是,不同的器件使用的TFS flash 类型有所不同。
根据具体Kinetis 器件的不同,flash 可能是FTFA 、FTFL 或FTFE 模块。
下表展示了flash 模块之间的差异。
应用笔记Rev 1, 05/2014Kinetis K 和L 系列MCU 的生产用Flash 编程最佳做法作者:Melissa Hunter© 2013–2014 Freescale Semiconductor, Inc.内容1简介..........................................................................12Kinetis flash 类型.....................................................13编程接口...................................................................24编程步骤...................................................................35其他编程考虑因素...................................................76常见问题...................................................................87扩展阅读. (98)修订历史记录 (9)3编程接口有两个主要物理接口可用于Kinetis 上的生产用flash 编程—SWD/JTAG 和EzPort 。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
飞思卡尔Flexmemory例程指南
例程功能
飞思卡尔Kinetis 100MHz Silicon1.x 产品flexmem_demo例程实现使用FlexRAM以及FlexNVM相互结合模拟出EEPROM的功能,其中划分FlexRAM的部分区域作为EEPROM的实际存储区域,划分FlexNVM的部分区域作为EEPROM的备份区。
模拟出EEPROM存储器后,采用PIT定时15秒写读EEPROM区域,并通过波特率为115200bps的串口打印方式记录。
运行平台
✓TWR-K40X256
✓TWR-SER (可选)
✓TWR-ELEV(可选)
✓CodeWarrior V10.x/IAR ARM IDE
FLASH内存模块简介
飞思卡尔FLASH内存模块包括以下几个内存区域:
∙编程flash-非易失性flash内存,用于存储编程代码与数据
∙FlexNVM-非易失性flash内存,用于存储编程代码,数据以及EEPROM的备份数据∙FlexRAM内存-可字节写RAM内存,用于传统RAM功能或者EEPROM的存储
K40芯片的内存大小及地址情况如下:
TWR-K40X256使用的芯片是K40X256VMD100和K40DX256ZVMD10的内存大小一样,即Pflash为256KB,FlexNVM为256KB,FlexRAM为4KB。
要采用FlexRAM以及FlexNVM实现EEPROM,首先需要划分FlexRAM以及FlexNVM的相关区域,FTFL模块有专门的EEPROM的分区指令如下:
其中,FCCOB4的值有两部分组成,即FCCOB4[EEESPLIT]和FCCOB4[EEESIZE]。
这两部的组合值决定了EEPROM两块内存(Subsystem A, Subsystem B)的比例以及大小,具体查看用户手册的表28-70. Valid EEPROM Data Set Size Codes.这部分内存来自FlexRAM。
FCCOB5的值即FCCOB5[DEPART],是用于划分FlexNVM区域,将此分为数据flash区域以及EEPROM备份区域两部分。
FlexNVM的总大小为256K。
具体的分区情况如下图所示,其中红色数据是本例程的分配值。
模拟出的EEPROM寿命的计算公式为:
其中,
Endurance: 每个FlexRAM区域平均最小的写次数。
E-flash:FlexNVM中每个Subsystem中用于EEPROM的备份区域大小。
EEESPLIT: subsystem的分配因子,值有1/8,1/4,1/2。
EEESIZE: 总的EEPROM的大小。
Record Efficiency: 写32bit与16bit为0.5;写8bit为0.25。
Baseline Endureance: 正常的flash寿命,10k次
本例程的
运行例程(CodeWarrior)
1)使用USB cable连接TWR-K40X256开发板Min-B USB连接器(J16);
2)加载Flexmem_demo工程:
∙选择菜单【File】->【Import】->【Existing Projects into
Workspace】
∙选择项目所在路径,并指定所要加载项目,点击完成:
3)选择【MK40X256VMD100_INTERNAL_RAM】,点击进行编译;
4)编译成功后,点击调试器箭头,选择【Debug Configurations】进入调试器配置
界面;
5)选择【k40-flexmem_demo_MK40X256VMD100_INTERNAL_RAM_PnE OSJTAG】,点
击【Debug】进入调试界面;
6)进入调试界面后,点击运行例程。
运行例程(IAR)
1)使用USB cable连接TWR-K40X256开发板Min-B USB连接器(J16);
2)加载Flexmem_demo工程后,选择【RAM_128KB】,点击进行编译;
3)编译成功后,点击进入调试界面;
4)进入调试界面后,点击运行例程。
串口配置
选择串口调试工具,使用下图配置信息;
注:其中端口号为实际硬件的串口号,查看【我的电脑】->【设备管理器】->【端口】。
代码说明
主程序代码说明,在文件flexmem_demo.c中
Main函数代码说明,在文件flexmem_demo.c中
Partition_flash()函数代码说明,在文件flexmem_demo.c中
PIT中断服务函数代码说明,在文件flexmem_demo.c中
Flexmem_d emo 例程主函数流程图
运行效果(通过串口助手查看)第一次,需要分区:
第二次,不需要分区:
参考资料
TWR-K40X256开发板用户手册:
/files/32bit/doc/ref_manual/TWR-K40X256-
UM.pdf?fpsp=1&WT_TYPE=Users
Guides&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation Kinetis K系列快速指南:
/files/32bit/doc/quick_ref_guide/KQRUG.pdf?fp sp=1&WT_TYPE=Quick Reference
Guides&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation
K40 100MHz Silicon1.x开发手册:
/files/32bit/doc/ref_manual/K40P144M100SF2RM. pdf?fpsp=1
K40 0M33Z勘误表:
/files/microcontrollers/doc/errata/KINETIS_0M 33Z.pdf?fpsp=1&WT_TYPE=Errata&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT _ASSET=Documentation。