【正文】
s 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 EPROM’s 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 patible. 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 EPROM’s are available from several different manufacturers. At least two, Microchip and Atmen, have patible chips. I haven39。 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 mon oversight, and a good source of bugs!Cycle lifeSerial EPROM’s are typically rated to endure 1 million write operations per byte. That’s 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 es for free, however, and you will find the software mands needed to work with the SPI memory is a little more plex than just doing memory writes. The basic operation of the SPI based EPROM’s is to lower the CS line, send a mand, 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 don39。Void sermem_Read (unsigned char *puffin cuff)。You can find the full source code in and , which are fairly well mented 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 , 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 ()。SummarySerial EEPROM provide a great way to store nonvolatile 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