




已阅读5页,还剩13页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
外文翻译Serial MemoriesOverviewMany of us like to use small, single chip micro controllers. They are relatively cheap, easy to wire up to make run, and over all just mighty convenient to use. One down side to using these single chip controllers is the lack of large amounts of memory. Sure, you can hook up external memory to most of them, but that requires a lot of work, and usually consumes other valuable resources, mainly the I/O pins that make the chip useful.There is help out there! There are several forms of memory that dont require the standard address bus and data bus wiring. These memories are called serial memories, and they are just the ticket to allow you to store large amounts of information without giving up those precious I/O lines. There are several different styles of serial EEPROM. The focus of this article is going to be SPI based devices. There are also 1, 2, and 3 wire serial EEPROM devices that function in a similar way, but have different interface logic.This article is going to introduce the basics of serial memories, and present the driver software needed to make it operate.Missing the BusThe big advantage to using a Serial EEPROM is that the wiring only requires 4 signal lines from the CPU to operate it. Compare this with a more standard memory, which requires an address bus and a data bus! The amount of glue logic required to make a Serial EEPROM operate is extremely low. For example, check out the following two packages. A traditional memory, such as a 27256, requires a 28-pin part to be wired into your circuit. There are 15 address lines, 8 output lines, plus assorted control lines. On the other hand, a serial EEPROM can be purchased using in a 8-pin package. There is 1 input line, 1 output line, 1 control line, and 1 clock line required. There are a couple of other control lines available, but are not actually required if you wish to avoid them. As you can imagine, these parts a lot easier to wire in, much smaller and best of all are mighty cheap! An 8kx8 part costs about $1.61 at Dig key.Of course, there are tradeoffs. Since the memory of the serial EEPROM is accessed one bit at a time, there is a speed penalty to be paid. However, these are still extremely fast parts. They can output their data at over 2 million bits per second, which is quite reasonable for many applications. So, for a small amount of software overhead and only 4 I/O pins, you can have yourself some substantial data storage!Would you like to super Size that?Serial EPROMs are available in a variety of different sizes. They seem to range from 128 bytes all the way up to 32k bytes. Atmen also has a 128k byte device that fits the same form factor. All of these parts are electrically compatible. However, some require minor software changes. For example, some allow writes of 32 bytes at a time, where others allow 64 bytes at a time. These minor differences are easily dealt with in software. It turns out that serial EPROMs are available from several different manufacturers. At least two, Microchip and Atmen, have compatible chips. I havent looked into the other manufacturers, but I would expect theirs may be as well. They are also available in several package sizes, including an 8pin DIP as well as SOIC surface mount. The BasicsThere are 8 pins on one of these parts. Here is a list and their functions1CSChip select. This is a critical pin on these parts. The CS line not only enables the part, but it also acts as the end of operation marker. More about this pin later 2SOSerial Output pin. In SPI terminology, this would be the Slave Out, and should be connected to the MISO pin of the SPI port. Data being output from the serial EEPROM is clocked out on this line.3WPThe WP pin allows for hardware write protection. If appropriate bits in the control register are set, then the WP pin will disable any write operations when the pin is held low. This would be appropriate when you want to have extra protection against software bugs, or when you intend for the part to be read only. The other option is to wire it high and leave it that way. 4GNDPower supply GND5SISerial Input pin. In SPI terminology, this would be the Slave In, and should be connected to the MOSI pin of the SPI port. Data being output by the CPU is clocked in on this line.6SCKSerial Clock. This is the SPI serial clock line. Each cycle of this clock causes the data registers to shift both in and out 1 bit. 7HOLDThis interesting pin places the state of the part on HOLD. This is useful if you have interrupt driven routines that need to access other parts on the SPI bus. By holding this line low, the part will ignore the SCK line, which in affect causes the part to hold its current state. Your interrupt routine can then use the SPI bus to access a different part, then return to the current operation by raising the HOLD line. If you dont plan on doing this, just wire it high.8VCCThe power supply line. Usually connected to +5 volts, though the range of voltages go as low as 2.2volts, depending on the part you are using(* denotes active LOW)The Block DiagramAs always, engineers love to see the block diagram! Here is the block diagram you will find in the documentation for the Microchip 25C640:As you can see, there are a few different parts called out in the block diagram. Of particular interest to us are the EEPROM Array, which is the actual EEPROM memory cells, the Status Register, which is a register that holds configuration and status information, and of course the Page Latches, which are the temporary holding areas for data being written. The other parts are also interesting, but I am going to ignore them for this article. A SchematicConnecting a serial EEPROM is really quite straight forward. I have been offering a board based on the 68HC912B32 Micro controller for some time now. I recently added a spot for a serial EEPROM to the backside of the board. The following snippet of the schematic shows the 25xxx series EEPROM connected to the SPI port for this board. Note that on my 912B32 board, this is an optional device. I left several cut jumpers (these are areas where the trace can be cut, and the wiring done differently) on the board, and they are shown on the schematic. Connecting up a serial EEPROM is pretty straight forward, and it can be added to almost any CPU that supports the SPI bus. Note that I have chosen to leave the WP (Write Protect) and HOLD lines wired high. I dont use them in my software, but you are certainly welcome to use them. On my board, you merely cut the trace on the jumper, and wire up the appropriate pins to a port for control.Table of commandsThere are a small number of commands that you can issue to the serial EEPROM. The following table is a quick summary.Instruction Instruction CodeDescriptionREAD0000 0011Read data from memory array beginning at selected addressWRITE0000 0010Write data to memory array beginning at selected addressWREN0000 0110Set the write enable latch (enable writing)WRDI0000 0100Clear the write enable latch (disable writing)RDSR0000 0101Read status registerWRSR0000 0001Write status registerEach instruction code has its own argument requirements. Read/Write, for example, is followed by an address. Writing the status register requires an 8-bit argument, and so on. A complete set of instructions and their formats are available in the data sheet for your particular part. Most of these SPI parts have extremely similar manuals! You can find a list of data sheets on the Microchip website at which will provide you with a lot of extra detail.Speed issuesMost parts can operate with transfer speeds in excess of 1 megabit per second. Some parts can go up to 8 megabits per second. You need to take this into consideration when you are selecting a part. Luckily, most of the SPI implementations, such as the 68HC11 and 68HC12 SPI ports, allow you to adjust the clock speed for the SPI port with a clock scalar. Thus, if you are connecting a 25LC640, for example, to a 16mhz 68HC12, you will need to select an SPI presale that slows the SPI bus down to 2mhz. This is a common oversight, and a good source of bugs!Cycle lifeSerial EPROMs are typically rated to endure 1 million write operations per byte. Thats pretty decent. However, you still need to be careful here that you are not constantly writing data to the part. EEPROM is not a substitute for general purpose RAM. If you write to these parts in a tight loop, it would only take an hour or so to exceed the 1million write operations. Your software needs to be written to take that into account. SoftwareAs you can see, wiring up an SPI based EEPROM to the SPI port is relatively simple. Nothing comes for free, however, and you will find the software commands needed to work with the SPI memory is a little more complex than just doing memory writes. The basic operation of the SPI based EPROMs is to lower the CS line, send a command, such as WRITE, followed by an address and the data, then raise the CS line. In a WRITE operation, raising the CS line causes the EEPROM to actually store the data. That is an important point you dont want to miss!Serial EPROMs allow you to write in page mode, which means you can send up to 1 PAGE of data at a time. The number of bytes in a PAGE depends on the specific part. For example, the Atmen 25128 uses a 64 byte PAGE. The Microchip 25C640 uses a 32 byte PAGE. The idea is that each time the address spans a PAGE boundary, you need to raise the CS line so that the chip can write is page into memory. The key thing to watch for is when the address crosses that page boundary. You can write between one and the PAGE size bytes, which means if you only want to write a single byte that is fine. If you continue to write after crossing the page boundary, then the subsequent writes will wrap around on the current page and overwrite previously written data, which isnt what you wanted to do!I have written a set of routines in Image craft C that deal with the serial EPROMs. I have included links to the source below. The software is structured in a simple way. There is an initialization routine, which sets up the SPI port appropriately. It also defines read and write operations. The read/write operations function the same basic way. You start the operation by calling the sermem_StartRead () function, giving the initial address. Then, you issue a series of sermem_Read () commands. When you are done, sermem_StopRead () is called. For ease of use, I have also defined a function called sermem_ReadBlock () that does the entire operation at once.The Write versions do the same basic functions. Here are the function prototypes from the sermon files: / Sermem.h - Copyright 1998 (c) Kevin W Ross, all rights reserved/ Accompanies sermem.c and defines some of the basic information needed to/ Deal with the serial EEPROM memories./ Device Profiles - Here are the variables needed for each specific type of/ chip. Some have different page sizes and data sizes/Void sermem_Initialize ();Void sermem_StartRead (into address);Void sermem_Read (unsigned char *puffin cuff);Void sermem_StopRead (void);Void sermem_ReadBlock (into address, unsigned char *puffin cuff);Void sermem_StartWrite (into address);Void sermem_Write (unsigned char *puffin cuff);Void sermem_StopWrite (void);Void sermem_WriteBlock (into address, unsigned char *puffin cuff);Void sermem_Fill (into address, unsigned char bitewing count);You can find the full source code in sermem.c and sermem.h, which are fairly well commented and pretty easy to follow. This code is written for the 68HC12 series of chips, but is really trivial to port to the 68HC11 (an excursive left to the reader!). Another file is called memtest.c, which is a test program that uses the routines.The Status RegisterAn important part of the serial EEPROM is the status register. I thought it important to point it out that you need to use this register. This register not only holds some configuration data that you will need to write to, it also contains an important bit called the WIP bit standing for Write In Progress. Serial EEPROM requires a burn time while it is saving data to the array. This can take up to 5 milliseconds, though it might be less. Rather than relying on a timer on your micro controller, you can check the status of this WIP flag to know when the part has finished writing the page and is ready for new data. Void sermem_StopWrite (void) / / Raise the CS line. That makes the memory part start its write cycle / Then wait for the WIP bit to be cleared / Do spi_deselect (); / Need to select the EEPROM for the read status operation spi_select (); Spinout (SERMEM_INST_RDSR); / The Write in Progress (WIP) flag is bit 1. Wait for it to go low While (spiting (SERMEM_INST_RDSR) & 0x01); Spi_deselect (); / Disallow further writes to the EEPROM. Prevents rouge clock signals / From corrupting your data! Sermem_WriteDisable ();Above I show my implementation of the sermem_StopWrite () function. This functions job is to cause the serial EEPROM to commit a previously transferred page to EEPROM. The function razes the CS line, and then issues a RDSR instruction and loops waiting for the WIP bit to go to zero. Note that the spi_deselect () and spi_select () instructions needed to be there. The state transition is important because the CS line is used as the primary handshake between the micro controller that the serial EEPROM. It signals the start and stop of operations. SummarySerial EEPROM provide a great way to store non-volatile data on a small micro controller project. They require few I/O lines, relatively fast read/write operations, and most operate from a single 5volt power supply. The software routines to drive these parts are not very complex. Next time you need to store some non-volatile data, such as configuration information or navigation maps, consider serial EEPROM.串行存储器概述我们中的许多人喜欢使用小型的独立芯片微控制器。它们相对较为便宜,容易接线运行,而且最重要的是使用非常方便。使用这些微控制器的一个不好的方面是它们缺乏大容量的存储器。当然,你可以给它们中的大多数挂上外部存储器,但是,那要做许多工作,而且通常要消耗其他有价值的资源,仅仅是那些输入/出引脚使芯片变得有用。这里能提供帮助!有几种形式的存储器不需要标准地址总线和数据总线配线方式。这些存储器称为串行存储器,它们允许你在不放弃那些珍贵的输入/出引线的条件下,存储大容量的信息。存在几种不同形式的串行电擦除可编程存储器。本文的焦点就是基于SPI(串行外围接口)的器件。也有1线,2线和3线式串行电擦除可编程存储器器件,它们以相似的方式工作,但是具有不同的接口逻辑。本文将介绍串行存储器的基础,并指出操作它所需要的驱动软件。总线不见了使用串行电擦除可编程存储器的最大优势是:配线时仅仅需要CPU的4根信号线来操作。与此比较,一个较为标准的存储器将需要地址总线和数据总线!操作串行电擦除可编程存储器所需要的组合逻辑数量是相当低的。例如,检验以下两个封装。一个传统的存储器,像27256,需要28个引脚来接线到你的电路。其中有15条地址线,8条输出线,还有多种控制线。另一方面,一个有8引脚封装的串行电擦除可编程存储器能够买到。其中有1条输入线,1条输出线,1条控制线,还需要1条时钟线。一些其他的控制线可能会用到,但是如果你希望不用它们,那么实际上并不需要。正如你能想象到的,这更容易接线,更小巧,而且最大的好处是非常便宜!一个8kx8器件在DIGIKEY的价格是1.61美元。当然,存在一些折中。由于串行电擦除可编程存储器每次访问一个bit,这要付出速度上的代价。然而,它们仍然是相当快速的器件。它们能以每秒200万bit的速度输出数据。这对于许多应用来说是很合适的。所以,对于小数量的软件开销和仅仅4个I/O引脚,你可以为自己存储一些基本数据。你想要一个大一点的型号吗?串行电擦除可编程存储器有各种型号可供使用。它们从128字节一直到32K字节不等。与此对应,Atmen也有一个128K字节的器件。所有这些器件在电气上都是兼容的。然而,一些器件需要有较小的软件变化。例如,某些器件允许一次写32字节,而其他的允许一次写64字节。这些较小的差别很容易在软件中解决。显然,串行电擦除可编程存储器可以从几个不同的厂商那里得到。至少两个,Microchip和Atmel,拥有兼容的芯片。我还没有考察其他的厂商,但是可以预见,它们的也同样(兼容)。它们(EEPROM)也有几种封装型号,包括一个8引脚双列直插封装以及SOIC。基础部分这些器件之一具有8个引脚。以下是引脚列举和它们的功能。1CS芯片选择。这是器件的一个标准引脚。CS线不仅使能器件,而且作为操作结束的标志。后面还有更多该引脚的描述。2SO串行输出引脚。用SPI的术语,就是Slave Out,它应该连接到SPI端口的MISO引脚。从串行电擦除可编程存储器输出的数据在此线上随时钟输出。3WP该引脚负责硬件的写保护。如果在控制寄存器中设置了合适的bit,那么WP引脚在低电平时将禁止任何写操作。这适合于当你想对软件错误有额外的保护,或者你打算仅仅从器件读出。其它选择时,WP被置为高电平。4GND接地端5SI串行输入引脚。用SPI的术语,就是Slave In,它应该连接SPI端口的MOSI引脚。CPU输出的数据在此线上随时钟输出。6SCK串行时钟。这是SPI串行时钟线。每个时钟周期引起数据寄存器移入和移出1bit7HOLD这个有趣的引脚将器件的状态设为“挂起”。如果你需要中断操作来访问其他SPI总线上的器件,那么该引脚是有用的。通过将此线拉低,器件将忽略SCK线,这实际上引起器件挂起它的当前状态。你的中断操作这时可以使用SPI总线访问不同的器件,然后通过升高HOLD线的电平返回当前操作。如果你不打算这样做,就给它接高电平。8VCC电源线。通常接5V,尽管电压范围可低至2.2V。这取决于你所用的器件。(*表示低电平有效)方块图通常,工程师们爱看方块图!下面就是你在本文中找到的Microchip 25C640的方块图:正如你所看到的,方块图里有一些不同的部分。对于我们尤其有趣的是EEPROM阵列(它实际上是EEPROM存储单元),状态寄存器(保存结构和状态信息),当然还有页锁存(它是暂时保存当前写入数据的区域)。其他部分也是有趣的,但是在这篇文章里我将忽略它们。一个示意图连接一个串行EEPROM是很简单的。我提供一个基于68HC912B32微控制器的板子已有一段时间了。最近我在板子的背面为串行EEPROM添加了一块地方。接下来示意的图片展示了连接到板子SPI端口的25xxx串行EEPROM。注意,在我的912B32板子上,这是一个最优器件。我在板子上留下了几个切换开关(在该区域,跟踪能被切断,配线方式不同)它们显示在示意图中。连上一个串行EEPROM太简单了,它能添加到几乎所有的CPU,只要该CPU支持SPI总线。注意,我已经选择将WP和HOLD线接为高电平。在我的软件中,我不使用它们,但我欢迎你使用它们。在我的板子上,你仅仅在开关上切断跟踪并为控制端口连接到合适的引脚就行了。命令表你可以发给串行EEPROM一些为数不多的命令。以下表格是一个简单的总结。指令 指令编码描述READ0000 0011从选择的存储器阵列地址开始读取数据WRITE0000 0010从选择的存储器阵列地址开始写入数据WREN0000 0110设置写使能锁存(能进行写操作)WRDI0000 0100清除写使能锁存(不能进行写操作)RDSR0000 0101读状态寄存器WRSR0000 0001写状态寄存器每个指令编码有它自己的格式要求。例如Read/Write,紧接着它的是地址。写入状态寄存器需要8bit的格式,等等。一套完整的指令及格式可以在你的特殊器件的数据手册上得到。多数SPI器件具有相当类似的手册!你能在下面的微芯片网址上找到数据手册的列表,里面将给你提供大量的额外细节。 速度问题多数器件能在传输速度超过1兆比特每秒的条件下操作。当你选择了一个器件后需要将此考虑进去。幸运的是,多数SPI的执行,例如68HC11和68HC12的SPI端口,允许你根据时钟标量来调整SPI端口的时钟速度。所以,如果你连接的是25LC640,例如,连到16mhz的68HC12,那将需要选择一个SPI比例因子来降低SPI总线到2mhz。这是个普通的疏忽,也是错误的重要来源!使用寿命串行EEPROM的典型值为每字节能承受一百万次写操作。这是相当好的。然而,在这里你仍然需要注意,你并不是不断地给器件写数据。EEPROM不是一般用途的RAM的替代品。如果你以一个短周期往这些器件(EEPROM)里写数据,那将仅仅花费一小时左右来超过一百万次写操作。你的软件在写的时候需要将此考虑进去。软件正如你所见到的,基于EEPROM的SPI配线到SPI端口相对简单。没有不需要代价的东西,然而,你将发现需要与SPI存储器一起工作的软件命令比存储器写操作更为复杂。基于EEPROM的SPI基本操作是拉低CS线,发送一条命令,像WRITE,接着是地址和数据,然后升高CS线。在一个WRITE操作中,升高CS线引起EEPROM存储数据。这是你不想丢掉(数据)的关键!串行EEPROM允许你以页模式进行写操作,那意味着你每次能发送1页数据。每页的字节数取决于具体的器件。例如,Atmel 25128使用64字节的页。微芯片25C640使用32字节的页。思路是每次地址跨越
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 农村电商服务体系建设实施方案:2025年农村电商金融服务创新与风险防控分析
- 地皮股东转让协议书
- 取消购房合同协议书
- 医院出租合同协议书
- 医院医生劳务协议书
- 合同生效赔偿协议书
- 单独车架购买协议书
- 公司购车内部协议书
- 2025年工业互联网平台雾计算协同机制与工业安全防护分析报告
- 项目管理中的解决方案试题及答案
- 湖南省长沙市师范大学附属中学2025届高三下学期模拟试卷二地理试题 含解析
- 产后康复培训课件
- 2025年中考历史总复习《中国历史》七年级上册全册重点知识复习梳理(全册)
- 足疗店装修施工合同协议
- 装饰布展项目合同协议
- 《骨膜下注射技术》课件
- JJG 134-2023 磁电式速度传感器检定规程
- (高清版)TDT 1055-2019 第三次全国国土调查技术规程
- 五金销售合同2023(含价格清单)
- 4车道高速公路30米预应力混凝土简支T梁桥上部结构设计_论文
- 2020年广东省中考物理试卷分析
评论
0/150
提交评论