Hi Ruben,

Try this. I have several methods for reading and writing to the M25Pxxx family. All work but the ones not commented out are the fastest. In some infrequent calls I have left the slow routines in place as they don't add any significan time to the download of data from the M25Pxxx memory.

[code]
ReadFromM25P128:
memclk = 0 'data change point
memclk = 1 : reply.7 = memq : memclk = 0
memclk = 1 : reply.6 = memq : memclk = 0
memclk = 1 : reply.5 = memq : memclk = 0
memclk = 1 : reply.4 = memq : memclk = 0
memclk = 1 : reply.3 = memq : memclk = 0
memclk = 1 : reply.2 = memq : memclk = 0
memclk = 1 : reply.1 = memq : memclk = 0
memclk = 1 : reply.0 = memq : memclk = 0
'takes 50 uSecs per character
debug #reply, ", " 'Debug takes 6.7 mSecs
return


RDSRWIP: 'reads the Status Register - waits for WIP bit to go low
'Data from M25P128 changes on fall of clock so sample on rise of clock.
code = $05 'Read Status Register code
gosub sendcode
WIPclr:
for shift = 7 to 0 step -1 'read 8 bit reply
high memclk : reply.0[shift] = memq : low memclk : pauseus 1
next shift
if reply.0 = 1 then wipclr
return

SendCode: 'Serial MSB first sends the CODE byte from PIC to M25P128
TRISE.0 = 0 : PortE.0 = 0 : memclk = 0 'MemClk
TRISC.0 = 0 : PortC.0 = 0 : memd = 0 'MemD
' for shift = 7 to 0 step -1 'send MSB first
' memclk = 0 : memd = code.0[shift] : memclk = 1: pauseus 1 : memclk = 0
' next shift 'this is SLOW ~500 uSecs per character
memclk = 0
memclk = 0 : memd = code.7 : memclk = 1
memclk = 0 : memd = code.6 : memclk = 1
memclk = 0 : memd = code.5 : memclk = 1
memclk = 0 : memd = code.4 : memclk = 1
memclk = 0 : memd = code.3 : memclk = 1
memclk = 0 : memd = code.2 : memclk = 1
memclk = 0 : memd = code.1 : memclk = 1
memclk = 0 : memd = code.0 : memclk = 1
' much faster, takes about 52 uSecs per character
return
/[code]

You can see here I have several methods for reading from the M25P128. The decrementing loop "... for shift = 7 to 0 step -1..." works and is simple BUT it takes about 500 uSecs per character.

HTH
BrianT