CortexM0_LPC1100_第4章 接口技术与可靠性设计 串行NOR Flash数据存储方案

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

广州周立功单片机发展有限公司Tel:(020)3873097638730977Fax:38730925章接口技术与可靠性设计······················································································14.1串行NORFlash数据存储方案·····················································································14.1.1串行NORFlash概述·····························································································14.1.2MX25L1605介绍···································································································11.简介·····················································································································12.引脚说明·············································································································13.应用电路·············································································································24.状态寄存器··········································································································25.写保护·················································································································34.1.3操作软件包·············································································································31.软件包结构··········································································································32.操作原理·············································································································44.1.4软件包详解·············································································································41.SPI初始化···········································································································42.SPI通讯函数·······································································································53.Flash擦除函数·····································································································74.写操作API··········································································································95.读操作API·········································································································116.读IDAPI···········································································································134.1.5软件包应用示例···································································································15v广州周立功单片机发展有限公司Tel:(020)3873097638730977Fax:38730925是用串口进行连续数据存取的小尺寸、低功耗Flash存储器;相对于并行Flash,它用更少的引脚传送数据,这降低了系统空间、功耗、成本。它内部的地址空间是线性的,随机访问速度快;它的传输效率高,在1~4MB的小容量时具有很高的性价比。更重要的是,串行NORFlash的读写操作十分简单。这些优势使得串行NORFlash被广泛地用于微型、低功耗的数据存储系统。串行NORFlash可通过SPI进行操作。用户根据NORFlash芯片自定义的协议,通过SPI发送命令到芯片,并接收NORFlash芯片返回的状态信息和数据信息。此外,用户在使用串行NORFlash时需要注意其支持哪些类型的SPI操作方式。4.1.2MX25L1605介绍1.简介MX25L1605是一款8位SPIFlash存储芯片,容量为16Mb,分为512个扇区,每个扇区大小为4KB,芯片地址空间如图4.1所示。图4.1MX25L1605地址空间MX25L1605芯片的读/写操作以字节为单位,能在2.7V~3.6V电源电压下完成读/写操作。2.引脚说明MX25L1605芯片引脚如图4.2所示,引脚功能描述见表4.1所示。图4.2芯片引脚1广州周立功单片机发展有限公司Tel:(020)3873097638730977Fax:38730925的片选线,该引脚电平为低时,芯片被使能SI/SIO0MX25L1605串行数据输入引脚SO/SIO1MX25L1605串行数据输出引脚SCLKMX25L1605串行时钟线WP#/ACC写保护:该引脚为高时,用户可进行编程或擦除HOLD#暂停控制引脚,低电平时有效VCC3.3V电源GND电源地3.应用电路MX25L1605的电源包括电源引脚、SPI接口引脚、控制引脚,芯片通过SPI和控制引脚与LPC1100系列Cortex-M0微控制器连接。接口电路中的/WP、/HOLD引脚可根据实际情况决定是否与LPC1100系列Cortex-M0微控制器引脚相连,也可外加上拉电阻,应用电路如图4.3所示。图4.3MX25L1605接口电路4.状态寄存器MX25L1605状态寄存器长度为1个字节,包括繁忙状态、写保护等级、烧写模式、写保护等级修改使能四个方面的信息。用户可通过状态寄存器获取芯片的工作信息、设定芯片参数。MX25L1605状态寄存器位功能说明如表4.2所示。表4.2状态寄存器位功能描述位名称功能0WIP为1时表明芯片正在进行操作1WEL为1时表明芯片写使能有效,为0时写使能无效2BP0该位和BP1、BP2、BP3一起决定写保护的等级3BP1该位和BP0、PB2、BP3一起决定写保护的等级4BP2该位和BP0、BP1、BP3一起决定写保护的等级5BP3该位和BP0、BP2、BP2一起决定写保护的等级6CPmode为1时是连续烧写模式,为0时是单字节烧写模式7SRWD为1时禁止写状态寄存器2广州周立功单片机发展有限公司Tel:(020)3873097638730977Fax:38730925.写保护用户可以通过状态寄存器里的写保护等级位BP0~BP3设定芯片写保护的块[1]范围。状态寄存器里BP0~BP3与写保护的等级关系如表4.3所示。表4.3写保护等级和BP0~3位的关系状态位BP3BP2BP1BP0保护的块0000无00011块:第31块00102块:第30块~第31块00113块:第28块~第31块01008块:第24块~第31块010116块:第16块~第31块011032块:第0块~第31块011132块:第0块~第31块100032块:第0块~第31块100132块:第0块~第31块101016块:第0块~第15块101124块:第0块~第23块110028块:第0块~第27块110130块:第0块~第29块111031块:第0块~第30块111132块:第0块~第31块[1]每一个块有16个扇区。4.1.3操作软件包随TinyM0配套了MX25L1605的操作软件包[1],用户可通过该软件包实现对该芯片的主要操作。注:软件包使用SSP0完成SPI功能;为了表述清晰,以下未经特殊说明统称SPI。1.软件包结构软件包共有18个函数,用户只需使用其中的4个用户API。由于用到SPI,用户还需调用SPI初始化函数。软件包结构如图4.4所示。图4.4MX25L1605操作软件包结构示意图3广州周立功单片机发展有限公司Tel:(020)3873097638730977Fax:38730925.操作原理MX25L1605定义了一系列操作指令用于实现芯片提供的底层操作[1],每个指令都有对应代码。只要将指令代码发送给芯片,芯片就会执行相应的底层操作。[1]MX25L1605所提供的底层操作包括单字节读/写数据、擦除扇区、读/写状态寄存器、设置写保护等。由于底层操作对用户透明,因此需要一个在用户和底层操作间完成数据交换的接口,即用户API。对用户而言使用方便。这些API函数能够将用户指定的功能分解成若干个底层操作,再调用SPI通讯函数来实现这些操作,最终实现用户要求的功能,用户API如表4.4所示。表4.4用户API汇总函数名称函数功能MX25L1605_RDID读取设备ID、厂商ID、JEDECIDMX25L1605_Erase指定起始扇区、终止扇区并完成擦除操作MX25L1605_WR连续向Flash写数据,地址不能超出最大地址范围MX25L1605_RD快速从Flash某一个地址处读取指定长度的数据4.1.4软件包详解1.SPI初始化使用软件包前,首先要初始化SPI。由于LPC1100系列Cortex-M0微控制器没有单独的SPI;所以将SSP0初始化为SPI模式,详见程序清单4.1所示。程序清单4.1SPI初始化/****************

1 / 17
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功