Author | Matthew Schinkel - borntechi.com, copyright © 2009, all rights reserved. |
Adapted-by | Sebastien Lelong |
Compiler | >=2.4l |
This is library for 23K256 SPI SRAM, Microchip's 20mhz 256kbit SRAM memory
http://ww1.microchip.com/downloads/en/DeviceDoc/22100D.pdf
Address from 0 to 32,767 This is a 2.7v to 3.6v memory. This lib should also work with 23k640 (64kbit sram), but hasn't been tested, please let me know. Also should work with 23A640 & 23A256 (1.5v to 1.95v versions), also not tested SPI Mode is 00 for 23k256
No dependency found
const byte SRAM_23K256_PAGE_MODE = 0b10
const byte SRAM_23K256_WRITE_SETTINGS = 0b_0000_0001
const byte SRAM_23K256_HOLD_DISABLE = 1
const byte SRAM_23K256_BYTE_MODE = 0b00
const byte SRAM_23K256_READ_COMMAND = 0b_0000_0011
const byte SRAM_23K256_HOLD_ENABLE = 0
const byte SRAM_23K256_WRITE_COMMAND = 0b_0000_0010
const byte SRAM_23K256_SEQUENTIAL_MODE = 0b01
const byte SRAM_23K256_READ_STATUS = 0b_0000_0101
sram_23k256_start_write(word in address)
sram_23k256_init(byte in sram_23k256_mode, byte in sram_23k256_hold_disable)
sram_23k256_byte'put(word in address, byte in data)
sram_23k256_do_read(byte out data)
sram_23k256_dword'put(word in address, dword in data)
sram_23k256_read_settings(byte out mode, byte out hold_is_disabled)
sram_23k256_do_write(byte in data)
sram_23k256_word'put(word in address, word in data)
sram_23k256_write(word in address, byte in data)
sram_23k256_read(word in address, byte out data)
sram_23k256_stop_read()
sram_23k256_start_read(word in address)
sram_23k256_stop_write()
sram_23k256_dword'get(word in address) return dword
sram_23k256_word'get(word in address) return word
sram_23k256_byte'get(word in address) return byte
const byte SRAM_23K256_PAGE_MODE = 0b10
send read command then read 1 32Byte page
const byte SRAM_23K256_WRITE_SETTINGS = 0b_0000_0001
Write STATUS register
const byte SRAM_23K256_HOLD_DISABLE = 1
disable the hold pin. (connect put pin direct to 3.3v)
const byte SRAM_23K256_BYTE_MODE = 0b00
constants for use with init procedure input data modes in witch to read and write data
const byte SRAM_23K256_READ_COMMAND = 0b_0000_0011
constants for internal usage
const byte SRAM_23K256_HOLD_ENABLE = 0
enable the hold pin (conect pin to microcontroller)
const byte SRAM_23K256_WRITE_COMMAND = 0b_0000_0010
Write data to memory array beginning at selected address
const byte SRAM_23K256_SEQUENTIAL_MODE = 0b01
send read command then read many bytes
const byte SRAM_23K256_READ_STATUS = 0b_0000_0101
Read STATUS register
sram_23k256_start_write(word in address)
get 23K256 ready for writing and select a address to start from (fast writes) do not interupt read process by switching to another spi device
sram_23k256_init(byte in sram_23k256_mode, byte in sram_23k256_hold_disable)
initialize startup settings & spi mode 00
sram_23k256_byte'put(word in address, byte in data)
Write to 23k256 as a byte array
sram_23k256_do_read(byte out data)
read byte from the 23K256
sram_23k256_dword'put(word in address, dword in data)
Write 23k256 as a large 8K dword array
sram_23k256_read_settings(byte out mode, byte out hold_is_disabled)
Reads the status/settings register to get the current 23k256 mode that was previously set in the init procedure. SRAM_23K256_BYTE_MODE, SRAM_23K256_SEQUENTIAL_MODE, SRAM_23K256_PAGE_MODE
sram_23k256_do_write(byte in data)
write byte to the 23K256 you may use spi_master directly instead.
sram_23k256_word'put(word in address, word in data)
Write 23k256 as a large 16K word array
sram_23k256_write(word in address, byte in data)
Write 1 byte to selected address
sram_23k256_read(word in address, byte out data)
Read 1 byte to selected address
sram_23k256_stop_read()
tell 23K256 you are finished reading
sram_23k256_start_read(word in address)
get 23K256 ready for reading and select a address to start from (fast reads) do not interupt read process by switching to another spi device
sram_23k256_stop_write()
tell 23K256 you are finished writing
sram_23k256_dword'get(word in address) return dword
Read from 23k256 as a large 8K dword array
sram_23k256_word'get(word in address) return word
Read from 23k256 as a large 16K word array
sram_23k256_byte'get(word in address) return byte
Read from 23k256 as a byte array