Difference between revisions of "Interfacing PIC with SPI memory"

From Mech
Jump to navigationJump to search
(Creating page)
 
Line 1: Line 1:
==Overview==
==Overview==
Sometimes, it can be useful to interface the PIC with an external memory for data logging or other reasons, since there is limited memory available on the PIC itself. There are various types of memory which a PIC can communicate with. One common type of memory is EEPROM memory, which is non-volatile, so it keeps its data when power is turned off. One type of EEPROM memory uses SPI to communicate with the PIC. This article discusses connecting the 25AA1024, a one megabit EEPROM, to a PIC 18F4520.
Sometimes, it can be useful to interface the PIC with an external memory for data logging or other reasons, since there is limited memory available on the PIC itself. There are various types of memory which a PIC can communicate with. One common type of memory is EEPROM memory, which is non-volatile, so it keeps its data when power is turned off. One type of EEPROM memory uses SPI to communicate with the PIC. This article discusses connecting the 25AA1024, a one megabit EEPROM, to a PIC 18F4520.
=Notes on the 25AA1024=
===Notes on the 25AA1024===
The 25AA1024 has one megabit (125 kbytes) of memory organized in pages of 256 bytes each.
The 25AA1024 has one megabit (125 kbytes) of memory organized in pages of 256 bytes each.
Like other EEPROMS, it has a page buffer which stores data as it is received, and then writes the buffer all at once to the EEPROM memory. Writing takes a long time compared to the speed of data transfer- the SPI line can run up to 20 Mhz, but a write cycle is up to 6 ms. Because only one page can be written every 6 ms, the PIC cannot necessarily continuously send data, unless the rate is less than 256 bytes per 6 ms. When sending data, if the address reaches a page boundary the data will "wrap around" in the page buffer. For instance, if the start address is 250, and a page boundary is at 256, then the seventh byte sent will be actually stored in address 0, not 257. Because of this, pages '''must''' be written when a page boundary is met and a write cycle needs to be restarted at an address in the next page.
Like other EEPROMS, it has a page buffer which stores data as it is received, and then writes the buffer all at once to the EEPROM memory. Writing takes a long time compared to the speed of data transfer- the SPI line can run up to 20 Mhz, but a write cycle is up to 6 ms. Because only one page can be written every 6 ms, the PIC cannot necessarily continuously send data, unless the rate is less than 256 bytes per 6 ms. When sending data, if the address reaches a page boundary the data will "wrap around" in the page buffer. For instance, if the start address is 250, and a page boundary is at 256, then the seventh byte sent will be actually stored in address 0, not 257. Because of this, pages '''must''' be written when a page boundary is met and a write cycle needs to be restarted at an address in the next page.

Revision as of 14:34, 17 November 2009

Overview

Sometimes, it can be useful to interface the PIC with an external memory for data logging or other reasons, since there is limited memory available on the PIC itself. There are various types of memory which a PIC can communicate with. One common type of memory is EEPROM memory, which is non-volatile, so it keeps its data when power is turned off. One type of EEPROM memory uses SPI to communicate with the PIC. This article discusses connecting the 25AA1024, a one megabit EEPROM, to a PIC 18F4520.

Notes on the 25AA1024

The 25AA1024 has one megabit (125 kbytes) of memory organized in pages of 256 bytes each. Like other EEPROMS, it has a page buffer which stores data as it is received, and then writes the buffer all at once to the EEPROM memory. Writing takes a long time compared to the speed of data transfer- the SPI line can run up to 20 Mhz, but a write cycle is up to 6 ms. Because only one page can be written every 6 ms, the PIC cannot necessarily continuously send data, unless the rate is less than 256 bytes per 6 ms. When sending data, if the address reaches a page boundary the data will "wrap around" in the page buffer. For instance, if the start address is 250, and a page boundary is at 256, then the seventh byte sent will be actually stored in address 0, not 257. Because of this, pages must be written when a page boundary is met and a write cycle needs to be restarted at an address in the next page. Other than the 3-wire serial interface, the chip also has an enable pin that must be low during write and read operations. Because of this, multiple 25AA1024s could be used, with each CE leading to a different pin on the PIC, so that many 25AA1024s could be used by the same PIC.

Circuit