Revision: 1443
Author: [email protected]
Date: Sun Nov  1 00:09:06 2009
Log: added 23k256 with samples
http://code.google.com/p/jallib/source/detail?r=1443

Added:
  /trunk/include/external/memory
  /trunk/include/external/memory/23k256
  /trunk/include/external/memory/23k256/sram_23k256.jal
  /trunk/sample/16f877_23k256.jal
  /trunk/sample/18f452_23k256.jal

=======================================
--- /dev/null
+++ /trunk/include/external/memory/23k256/sram_23k256.jal       Sun Nov  1  
00:09:06 2009
@@ -0,0 +1,393 @@
+-- Title: 23K256 sram library
+-- Author: Matthew Schinkel - borntechi.com, copyright (c) 2009, all  
rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4l
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
+--
+-- Description: This is library for 23K256 SPI SRAM, Microchip's 20mhz  
256kbit SRAM memory
+--
+-- Sources:
+-- http://ww1.microchip.com/downloads/en/DeviceDoc/22100D.pdf
+--
+-- Functions descriptions:
+-- sram_23k256_init            - initialize startup settings & spi mode 00
+-- sram_23K256_read_settings   - Reads the settings register to get the  
current 23k256 mode
+-- sram_23K256_write           - Write one byte to selectd address
+-- sram_23K256_read            - Read one byte to selectd address
+-- sram_23K256_byte[address]   - Use as a 32K byte array
+-- sram_23K256_word[address]   - Use as a 16K word array
+-- sram_23K256_dword[address]  - Use as a 8K dword array
+--
+-- sram_23K256_start_write     - get 23K256 ready for writing and
+--                               select a address to start from (fast  
writes)
+-- sram_23K256_do_write        - write byte to the 23K256
+-- sram_23K256_stop_write      - tell 23K256 you are finished writing
+--
+-- sram_23K256_start_read      - get 23K256 ready for reading and
+--                               select a address to start from (fast  
reads)
+-- sram_23K256_do_read         - read byte from the 23K256
+-- sram_23K256_stop_read       - tell 23K256 you are finished reading
+--
+-- Notes:
+-- 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
+--
+-- Array Usage:
+-- If you are using a procedure that reads/write more then one byte you  
must
+-- set SEQUENTIAL_MODE & must use the chip select pin.
+--
+-- Set mode before each read/write. Must be TRUE if more then one  
component is
+-- on bus using different spi modes.
+--
+const byte SRAM_23K256_ALWAYS_SET_SPI_MODE = TRUE
+
+-- constants for use with init procedure input data
+-- modes in witch to read and write data
+const byte SRAM_23K256_BYTE_MODE = 0b00               -- read only one byte
+const byte SRAM_23K256_SEQUENTIAL_MODE = 0b01         -- send read command  
then read many bytes
+const byte SRAM_23K256_PAGE_MODE = 0b10               -- send read command  
then read 1 32Byte page
+
+const byte SRAM_23K256_HOLD_DISABLE = 1               -- disable the hold  
pin. (connect put pin direct to 3.3v)
+const byte SRAM_23K256_HOLD_ENABLE  = 0               -- enable the hold  
pin   (conect pin to microcontroller)
+
+-- constants for internal usage
+const byte SRAM_23K256_READ_COMMAND  = 0b_0000_0011   -- Read data from  
memory array beginning at selected address
+const byte SRAM_23K256_WRITE_COMMAND = 0b_0000_0010   -- Write data to  
memory array beginning at selected address
+const byte SRAM_23K256_READ_STATUS  = 0b_0000_0101    -- Read STATUS  
register
+const byte SRAM_23K256_WRITE_SETTINGS  = 0b_0000_0001 -- Write STATUS  
register
+
+
+--  
----------------------------------------------------------------------------
+-- initialize startup settings & spi mode 00
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_init(byte in sram_23k256_mode, byte in  
sram_23k256_hold_disable) is
+  -- put spi into the correct mode
+  SSPCON_CKP = 0
+  SSPSTAT_CKE = 1
+
+  sram_23k236_chip_select = low      -- enable the chip
+
+  -- choose the 23k256 read & write mode depending on mode input
+  if sram_23k256_mode == SRAM_23K256_BYTE_MODE then
+    spi_master_hw = SRAM_23K256_WRITE_SETTINGS
+    spi_master_hw = 0x00 + SRAM_23K256_HOLD_DISABLE
+  end if
+  if sram_23k256_mode == SRAM_23K256_SEQUENTIAL_MODE then
+    spi_master_hw = SRAM_23K256_WRITE_SETTINGS
+    spi_master_hw = 0x40 + SRAM_23K256_HOLD_DISABLE
+  end if
+  if sram_23k256_mode == SRAM_23K256_PAGE_MODE then
+    spi_master_hw = SRAM_23K256_WRITE_SETTINGS
+    spi_master_hw = 0x80 + SRAM_23K256_HOLD_DISABLE
+  end if
+
+  sram_23k236_chip_select = high        -- disable the chip
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- 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
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_read_settings(byte out mode, byte out  
hold_is_disabled) is
+  var byte settings
+
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  sram_23k236_chip_select = low           -- enable the chip
+  spi_master_hw = SRAM_23K256_READ_STATUS -- send read status command
+  settings = spi_master_hw                -- get the status byte
+  sram_23k236_chip_select = high          -- disable the chip
+
+  var bit read_hold at settings : 0       -- get bit "hold is disabled"  
from 23k256 status register byte
+  hold_is_disabled = read_hold
+
+  var bit mode_bit_0 at settings : 6      -- get 2 bit "mode" from 23k256  
status register byte
+  var bit mode_bit_1 at settings : 7
+
+  mode = mode_bit_1                       -- put 2 bit "mode" into a byte
+  mode = mode << 1
+  mode = mode + mode_bit_0
+
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- Write 1 byte to selected address
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_write(word in address, byte in data) is
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  var byte addr[4] at address
+
+  sram_23k236_chip_select = low             -- enable the chip
+  spi_master_hw = SRAM_23K256_WRITE_COMMAND -- send the write command
+  spi_master_hw = addr[1]                   -- send the address
+  spi_master_hw = addr[0]
+  spi_master_hw = data                      -- send the data byte
+
+  sram_23k236_chip_select = high            -- disable the chip
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- Read 1 byte to selected address
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_read(word in address, byte out data) is
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  var byte addr[4] at address
+
+  sram_23k236_chip_select = low              -- enable the chip
+  spi_master_hw = SRAM_23K256_READ_COMMAND   -- send the read command
+  spi_master_hw = addr[1]                    -- send the address
+  spi_master_hw = addr[0]
+  data = spi_master_hw                       -- get the data
+  sram_23k236_chip_select = high             -- disable the chip
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- Write to 23k256 as a byte array
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_byte'put(word in address, byte in data) is
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  var byte addr[4] at address
+
+  sram_23k236_chip_select = low             -- enable the chip
+  spi_master_hw = SRAM_23K256_WRITE_COMMAND -- send the write command
+  spi_master_hw = addr[1]                   -- send the address
+  spi_master_hw = addr[0]
+  spi_master_hw = data                      -- send the data byte
+
+  sram_23k236_chip_select = high            -- disable the chip
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- Read from 23k256 as a byte array
+--  
----------------------------------------------------------------------------
+function sram_23k256_byte'get(word in address) return byte is
+  var byte data
+
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  var byte addr[4] at address
+
+  sram_23k236_chip_select = low              -- enable the chip
+  spi_master_hw = SRAM_23K256_READ_COMMAND   -- send the read command
+  spi_master_hw = addr[1]                    -- send the address
+  spi_master_hw = addr[0]
+  data = spi_master_hw                       -- get the data
+  sram_23k236_chip_select = high             -- disable the chip
+
+  return data                                -- return the byte data
+end function
+
+--  
----------------------------------------------------------------------------
+-- Write 23k256 as a large 16K word array
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_word'put(word in address, word in data) is
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  address = address * 2                     -- multiply by 2 for word  
address
+
+  var byte full_data[2] at data
+
+  var byte addr[4] at address
+
+  sram_23k236_chip_select = low             -- enable the chip
+  spi_master_hw = SRAM_23K256_WRITE_COMMAND -- send the write command
+  spi_master_hw = addr[1]                   -- send the address
+  spi_master_hw = addr[0]
+
+  spi_master_hw = full_data[1]              -- send byte 1
+  spi_master_hw = full_data[0]              -- send byte 0
+
+  sram_23k236_chip_select = high            -- disable the chip
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- Read from 23k256 as a large 16K word array
+--  
----------------------------------------------------------------------------
+function sram_23k256_word'get(word in address) return word is
+  var word data
+
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  address = address * 2                     -- multiply by 2 for word  
address
+
+  var byte full_data[2] at data
+
+  var byte addr[4] at address
+
+  sram_23k236_chip_select = low             -- enable the chip
+  spi_master_hw = SRAM_23K256_READ_COMMAND  -- send the read command
+  spi_master_hw = addr[1]                   -- send the address
+  spi_master_hw = addr[0]
+
+  full_data[1] = spi_master_hw              -- get byte 1
+  full_data[0] = spi_master_hw              -- get byte 0
+
+  sram_23k236_chip_select = high            -- disable the chip
+
+  return data                               -- return the word data
+end function
+
+--  
----------------------------------------------------------------------------
+-- Write 23k256 as a large 8K dword array
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_dword'put(word in address, dword in data) is
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  address = address * 4                     -- multiply by 4 for dword  
address
+
+  var byte full_data[4] at data
+
+  var byte addr[4] at address
+
+  sram_23k236_chip_select = low             -- enable the chip
+  spi_master_hw = SRAM_23K256_WRITE_COMMAND -- send the write command
+  spi_master_hw = addr[1]                   -- send the address
+  spi_master_hw = addr[0]
+
+  spi_master_hw = full_data[3]              -- send byte 3
+  spi_master_hw = full_data[2]              -- send byte 2
+  spi_master_hw = full_data[1]              -- send byte 1
+  spi_master_hw = full_data[0]              -- send byte 0
+
+  sram_23k236_chip_select = high            -- disable the chip
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- Read from 23k256 as a large 8K dword array
+--  
----------------------------------------------------------------------------
+function sram_23k256_dword'get(word in address) return dword is
+  var dword data
+
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  address = address * 4                     -- multiply by 4 for dword  
address
+
+  var byte full_data[4] at data
+
+  var byte addr[4] at address
+
+  sram_23k236_chip_select = low             -- enable the chip
+  spi_master_hw = SRAM_23K256_READ_COMMAND  -- send the read command
+  spi_master_hw = addr[1]                   -- send the address
+  spi_master_hw = addr[0]
+
+  full_data[3] = spi_master_hw              -- get byte 3
+  full_data[2] = spi_master_hw              -- get byte 2
+  full_data[1] = spi_master_hw              -- get byte 1
+  full_data[0] = spi_master_hw              -- get byte 0
+
+  sram_23k236_chip_select = high            -- disable the chip
+
+  return data                               -- return the dword data
+end function
+
+--  
----------------------------------------------------------------------------
+-- get 23K256 ready for writing and select a address to start from (fast  
writes)
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_start_write(word in address) is
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  var byte addr[2] at address
+
+  sram_23k236_chip_select = low             -- enable the chip
+  spi_master_hw = SRAM_23K256_WRITE_COMMAND -- send the write command
+  spi_master_hw = addr[1]                   -- send the address
+  spi_master_hw = addr[0]
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- write byte to the 23K256
+-- you may use spi_master_hw directly instead.
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_do_write(byte in data) is
+  spi_master_hw = data                      -- send the data byte
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- tell 23K256 you are finished writing
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_stop_write() is
+  sram_23k236_chip_select = high            -- disable the chip
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- get 23K256 ready for reading and select a address to start from (fast  
reads)
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_start_read(word in address) is
+  -- put spi into mode 00
+  if SRAM_23K256_ALWAYS_SET_SPI_MODE == TRUE then
+    SSPCON_CKP = 0
+    SSPSTAT_CKE = 1
+  end if
+
+  var byte addr[2] at address
+
+  sram_23k236_chip_select = low              -- enable the chip
+  spi_master_hw = SRAM_23K256_READ_COMMAND   -- send the read command
+  spi_master_hw = addr[1]                    -- send the address
+  spi_master_hw = addr[0]
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- read byte from the 23K256
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_do_read(byte out data) is
+  data = spi_master_hw                       -- get the data
+end procedure
+
+--  
----------------------------------------------------------------------------
+-- tell 23K256 you are finished reading
+--  
----------------------------------------------------------------------------
+procedure sram_23k256_stop_read() is
+  sram_23k236_chip_select = high             -- disable the chip
+end procedure
+
=======================================
--- /dev/null
+++ /trunk/sample/16f877_23k256.jal     Sun Nov  1 00:09:06 2009
@@ -0,0 +1,135 @@
+-- Title: 23k256 sram example
+-- Author: Matthew Schinkel - borntechi.com, copyright (c) 2009, all  
rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4l
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license  
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: This library provides example usage for 23k256 sram
+--
+-- includes examples for:             : initalize
+--                                    : read settings from status register
+--                                    : write address
+--                                    : read address
+--                                    ; Do a large fast write
+--                                    ; Do a large fast read
+--                                    : Use as a 32K byte array
+--                                    : Use as a 16K word array
+--                                    : Use as a 8K dword array
+--
+-- Sources:
+-- http://ww1.microchip.com/downloads/en/DeviceDoc/22100D.pdf
+--  
http://www.microchip.com/stellent/groups/techpub_sg/documents/devicedoc/en026368.pdf
+--
+
+include 16F877                    -- target PICmicro
+;include 18f452                    -- target PICmicro
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target clock 20_000_000     -- oscillator frequency
+-- configure fuses
+pragma target OSC  HS              -- HS crystal or resonator
+pragma target WDT  disabled        -- no watchdog
+pragma target LVP  disabled        -- no Low Voltage Programming
+
+enable_digital_io()                -- disable analog I/O (if any)
+
+-- setup uart for communication
+const serial_hw_baudrate  = 38400   -- set the baudrate
+include serial_hardware
+serial_hw_init()
+
+-- setup spi
+include spi_master_hw         -- includes the spi library
+-- define spi inputs/outputs
+pin_sdi_direction = input    -- spi input
+pin_sdo_direction = output   -- spi output
+pin_sck_direction = output   -- spi clock
+
+-- setup chip select pin
+ALIAS sram_23k256_chip_select             is pin_a2
+ALIAS sram_23k256_chip_select_direction   is pin_a2_direction
+-- initial settings
+sram_23k256_chip_select_direction = output    -- chip select/slave select  
pin
+sram_23k256_chip_select = high                -- start chip slect high  
(chip disabled)
+--
+
+spi_init(SPI_MODE_11,SPI_RATE_FOSC_16) -- init spi, choose mode and speed
+
+_usec_delay (100_000)  -- wait for power to settle
+------------------------------------------------------------------------------
+
+-- initalize 23k256 in byte mode
+include sram_23k256 -- setup Microchip 23k256 sram
+sram_23k256_init(SRAM_23K256_SEQUENTIAL_MODE, SRAM_23K256_HOLD_DISABLE)   
-- init 23k256 in sequential mode
+
+-- example: read the settings that where selected during init
+var byte mode, hold_is_disabled
+sram_23k256_read_settings (mode, hold_is_disabled)
+
+serial_hw_write (mode)                -- send mode to serial port
+serial_hw_write (hold_is_disabled)    -- send hold value (true 1 or false  
0)
+
+-- example write then read from address 1
+sram_23k256_write(1,0xAA)   -- write byte
+
+var byte data1
+sram_23k256_read (1, data1) -- read byte
+
+-- send result via serial port
+serial_hw_write (data1)
+serial_hw_write (data1)
+serial_hw_write (data1)
+serial_hw_write (data1)
+
+-- Example using 23k256 as a 32KByte array (at array address 2)
+sram_23k256_byte[2] = 0xBB   -- set array byte 2 to value 0xBB
+data1 = sram_23k256_byte[2]  -- read array dword 2, data2 should = 0xBB
+
+-- send byte result via serial port
+serial_hw_write (data1)
+serial_hw_write (data1)
+serial_hw_write (data1)
+serial_hw_write (data1)
+
+-- procedure for sending dword via serial port
+procedure SEND_DWORD(DWORD in dval1) is
+  var byte dval2[4] at dval1
+  serial_hw_write (dval2[3])
+  serial_hw_write (dval2[2])
+  serial_hw_write (dval2[1])
+  serial_hw_write (dval2[0])
+end procedure
+
+-- Example using 23k256 as a 8K dword array
+var dword data2
+sram_23k256_dword[3] = 0xCCDDEEFF -- set array dword 3 to value 0xCCDDEEFF
+data2 = sram_23k256_dword[3]      -- read array dword 3, data2 should =  
0xCCDDEEFF
+
+-- send dword result via serial port
+send_dword (data2)
+send_dword (data2)
+send_dword (data2)
+send_dword (data2)
+
+-- Example fast write lots of data
+sram_23k256_start_write (10)
+for 1024 loop
+  sram_23k256_do_write (0x11)
+end loop
+sram_23k256_stop_write()
+
+-- Example fast read lots of data
+sram_23k256_start_read (10)
+for 1024 loop
+  sram_23k256_do_read (data1)
+  serial_hw_write (data1)
+end loop
+sram_23k256_stop_read()
+
+-- send 0xFF to serial port twice
+serial_hw_write (0xFF)
+serial_hw_write (0xFF)
+
=======================================
--- /dev/null
+++ /trunk/sample/18f452_23k256.jal     Sun Nov  1 00:09:06 2009
@@ -0,0 +1,135 @@
+-- Title: 23k256 sram example
+-- Author: Matthew Schinkel - borntechi.com, copyright (c) 2009, all  
rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4l
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license  
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: This library provides example usage for 23k256 sram
+--
+-- includes examples for:             : initalize
+--                                    : read settings from status register
+--                                    : write address
+--                                    : read address
+--                                    ; Do a large fast write
+--                                    ; Do a large fast read
+--                                    : Use as a 32K byte array
+--                                    : Use as a 16K word array
+--                                    : Use as a 8K dword array
+--
+-- Sources:
+-- http://ww1.microchip.com/downloads/en/DeviceDoc/22100D.pdf
+--  
http://www.microchip.com/stellent/groups/techpub_sg/documents/devicedoc/en026368.pdf
+--
+
+;include 16F877                    -- target PICmicro
+include 18f452                    -- target PICmicro
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target clock 20_000_000     -- oscillator frequency
+-- configure fuses
+pragma target OSC  HS              -- HS crystal or resonator
+pragma target WDT  disabled        -- no watchdog
+pragma target LVP  disabled        -- no Low Voltage Programming
+
+enable_digital_io()                -- disable analog I/O (if any)
+
+-- setup uart for communication
+const serial_hw_baudrate  = 38400   -- set the baudrate
+include serial_hardware
+serial_hw_init()
+
+-- setup spi
+include spi_master_hw         -- includes the spi library
+-- define spi inputs/outputs
+pin_sdi_direction = input    -- spi input
+pin_sdo_direction = output   -- spi output
+pin_sck_direction = output   -- spi clock
+
+-- setup chip select pin
+ALIAS sram_23k256_chip_select             is pin_a2
+ALIAS sram_23k256_chip_select_direction   is pin_a2_direction
+-- initial settings
+sram_23k256_chip_select_direction = output    -- chip select/slave select  
pin
+sram_23k256_chip_select = high                -- start chip slect high  
(chip disabled)
+--
+
+spi_init(SPI_MODE_11,SPI_RATE_FOSC_16) -- init spi, choose mode and speed
+
+_usec_delay (100_000)  -- wait for power to settle
+------------------------------------------------------------------------------
+
+-- initalize 23k256 in byte mode
+include sram_23k256 -- setup Microchip 23k256 sram
+sram_23k256_init(SRAM_23K256_SEQUENTIAL_MODE, SRAM_23K256_HOLD_DISABLE)   
-- init 23k256 in sequential mode
+
+-- example: read the settings that where selected during init
+var byte mode, hold_is_disabled
+sram_23k256_read_settings (mode, hold_is_disabled)
+
+serial_hw_write (mode)                -- send mode to serial port
+serial_hw_write (hold_is_disabled)    -- send hold value (true 1 or false  
0)
+
+-- example write then read from address 1
+sram_23k256_write(1,0xAA)   -- write byte
+
+var byte data1
+sram_23k256_read (1, data1) -- read byte
+
+-- send result via serial port
+serial_hw_write (data1)
+serial_hw_write (data1)
+serial_hw_write (data1)
+serial_hw_write (data1)
+
+-- Example using 23k256 as a 32KByte array (at array address 2)
+sram_23k256_byte[2] = 0xBB   -- set array byte 2 to value 0xBB
+data1 = sram_23k256_byte[2]  -- read array dword 2, data2 should = 0xBB
+
+-- send byte result via serial port
+serial_hw_write (data1)
+serial_hw_write (data1)
+serial_hw_write (data1)
+serial_hw_write (data1)
+
+-- procedure for sending dword via serial port
+procedure SEND_DWORD(DWORD in dval1) is
+  var byte dval2[4] at dval1
+  serial_hw_write (dval2[3])
+  serial_hw_write (dval2[2])
+  serial_hw_write (dval2[1])
+  serial_hw_write (dval2[0])
+end procedure
+
+-- Example using 23k256 as a 8K dword array
+var dword data2
+sram_23k256_dword[3] = 0xCCDDEEFF -- set array dword 3 to value 0xCCDDEEFF
+data2 = sram_23k256_dword[3]      -- read array dword 3, data2 should =  
0xCCDDEEFF
+
+-- send dword result via serial port
+send_dword (data2)
+send_dword (data2)
+send_dword (data2)
+send_dword (data2)
+
+-- Example fast write lots of data
+sram_23k256_start_write (10)
+for 1024 loop
+  sram_23k256_do_write (0x11)
+end loop
+sram_23k256_stop_write()
+
+-- Example fast read lots of data
+sram_23k256_start_read (10)
+for 1024 loop
+  sram_23k256_do_read (data1)
+  serial_hw_write (data1)
+end loop
+sram_23k256_stop_read()
+
+-- send 0xFF to serial port twice
+serial_hw_write (0xFF)
+serial_hw_write (0xFF)
+

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to