13.07.2015 Views

X25640_8Kb_Serial_EE.. - ISL

X25640_8Kb_Serial_EE.. - ISL

X25640_8Kb_Serial_EE.. - ISL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Using the Xicor <strong>X25640</strong> 8kB <strong>EE</strong>PROMBASIC Stamp II (BS2-IC) Program Listing' Program: XICOR8K.BS2' This program demonstrates subroutines for storing data in a' XICOR <strong>X25640</strong> serial <strong>EE</strong>PROM using the BASIC Stamp II (BS2).CS con 0 ' Chip-select line to pin 0.CLK con 1 ' Clock line to pin 1.DATA_N con 2 ' Pin # (2) of DATA line.Read<strong>EE</strong> con 3 ' <strong>EE</strong>PROM opcode for read.WREN con 6 ' <strong>EE</strong>PROM opcode to enable writes.WRDI con 4 ' <strong>EE</strong>PROM opcode to disable writes.RDSR con 5 ' <strong>EE</strong>PROM opcode to read status register.Write<strong>EE</strong> con 2 ' <strong>EE</strong>PROM opcode for write.<strong>EE</strong>addr var word ' <strong>EE</strong>PROM address for reads or writes.<strong>EE</strong>data var byte ' Data written/read to/from <strong>EE</strong>PROM.<strong>EE</strong>stats var byte ' Copy of the <strong>EE</strong>PROM status register.<strong>EE</strong>busy var <strong>EE</strong>stats.bit0 ' <strong>EE</strong>PROM busy bit.' Demonstration program. We're just going to write-enable' the <strong>EE</strong>PROM, write a value to one of its addresses, then retrieve' that value.Demo:high CS' Deactivate <strong>EE</strong>PROM.pause 100' Wait for settling.<strong>EE</strong>data = 113 ' Write the value 113 to address 8191.<strong>EE</strong>addr = 8191gosub <strong>EE</strong>nable' Enable the <strong>EE</strong>PROM for writes.gosub <strong>EE</strong>write' Write the data.is_busy:' Stay in a loop until <strong>EE</strong>PROM finishes write.gosub Read_stats ' Read status register.if <strong>EE</strong>busy = 1 then is_busy ' Wait until busy bit says 'done.'gosub <strong>EE</strong>read' Now read back the data and..debug ? <strong>EE</strong>data ' ..display it on the PC screen.STOP' End program.' ==================================================================' The subroutines for reading and writing the <strong>EE</strong>PROM.' ==================================================================' Write-enable the <strong>EE</strong>PROM.<strong>EE</strong>nable:low CSshiftout DATA_N,CLK,msbfirst,[WREN]high CS' Deactivate the <strong>EE</strong>PROM.return' Activate the <strong>EE</strong>PROM.' Send the enable opcode.' Return to program.sales / technical support (916) 624-8333 • fax (916) 624-8003pictech@parallainc.com • stamptech@parallaxinc.com Page 10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!