In C3 board there are two SRAM banks at channel 1 and 2, let's see how to access them.

The SRAM Chip used in C3 is: 23K256 a 256 Kbit Serial SRAM device. as a common serial protocol device to communicate with ityou need to send data bit in a serial sequence, driving the chip with a clock pulse for each bit to send/receive.

This device needs to be setup before reading or writing data, just by sending some command words that setup the right function of the chip.

As you can read from the datasheet, there are few commands to send:

Function Command bits Description
READ 0000 0011 Read data from memory array beginning at selected address
WRITE 0000 0010 Write data to memory array beginning at selected address
RDSR 0000 0101
Read STATUS register
WRSR 0000 0001 Write STATUS register

So before sending data, you need to setup the function of the chip, then you need to setup also the mode so the chip will know how to handle data you will send. 

This is done by setting up the status register bits 7 and 6:

Bits 7 6 Mode Description
11 Reserved Reserved
10 Page mode Reads/write a sequence a page ( block ) of 32 bytes each access *
01 Sequential mode Reads/write a sequence an undefined number of bytes each access *
00 Single byte Reads/write a byte each access *

(*) A typical access is made by lowering CS line, sending data and rising CS to complete.

Since the makin routine of SRAM is a typical SPI send/write routine you only need to implement some macro commands that send exact sequence to setup for writing/reading etc... because you already have made the SPI access routines.

A typical example that you will find in the source code is this one. The macro commands are defined in SPIN public functions. Of course you can make these functions in asm, it's up to you.

PUB SRAM_Rd_byte( ch, addr ) |i,c

   SPI_Set_Channel( 1+ch )
   SRAM_Write_Read( 24, $FF, %11_0000000000000000 addr ) ' SRAM read command

   c := SRAM_Write_Read( 8$FF, $FF )

   SPI_Set_Channel( 0 )

   return c  

PUB SRAM_Write_Read( num_bits, bit_mask, data_out ) |val, wait

   wait := 1

   setcommand( _sramWrRd, @num_bits )
   repeat until wait == 0

   Result := val