In SX Microcontrollers, SX/B Compiler and SX-Key Tool, kmonsx wrote: I've written a routine to copy a byte of data from a serial memory chip (Ramtron FM25256) to a variable. SCK = serial memory clock pin SO = serial output pin from memory to SX Note that the memory is already primed and already has the first bit of the byte on the SO pin prior to entering this routine. [code] MOV nsb, #8 CLR gotdata 'this is unnecessary loopzz: SETB SCK 'outputs are latched on falling edge, this just raises the clock 'note that the other instructions that follow serve to allow 'at least 28ns for a minimum clock high time. MOVB C, SO 'read the bit into carry RL gotdata 'bring the bit via carry into gotdata, leftshifting for MSB DEC nsb 'decrement bit counter CLRB SCK 'drop clock (clock low min is 28ns, data not valid until Todv, or 24ns) 'data comes valid 24ns after this clock drop. JNZ loopzz 'delay here is long enough for Todv and Tcl(clock low time) [/code] My serial memory can run pretty fast, up to 15mhz clock. MOVB is a multi-word 4-cycle instruction. As a result, it's expensive. The code works fine, but is there a way to optimize it? Thanks Keith ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=228013 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)