Hi guys , when using the routines , i found that i often use "data_length" varable to reflect the TOTAL amount of bytes used in the buffer , eg datalength = 32 , thus the data buffer should have 32 bytes ,

but the Flash_comand routine code uses " for 0 to Data_length , thus the buffer need to have 33 bytes of valid data , in this example

As a result the code changes to

" for 0 to Data_length-1"

ammed to

Code:
  For SDC_index = 0 To Data_Length-1             ' DATA LENGTH -1 COS 0 USED 
              if SDC_cmd <= 2 then                       ' if write or Write register then 
                 SDC_data_out = SDC_buffer[SDC_index]    ' send contents of indexed SDC_buffer 
                 gosub  Flash_SPIw  	                 ' write byte SDC_data_in from SPI bus.  Returns SDC_data_in.
              endif
            
              if SDC_cmd =>6 and SDC_cmd <=9 then       ' if 6= read signature byte, 7=read data normalspeed, 8= read data at Highspeed , 9=read ID
                 gosub  Flash_SPIR  	                 ' Read Byte SDC_data_in from SPI bus.  Returns SDC_data_in.
 	             SDC_buffer[SDC_index] = SDC_data_in
              endif
          Next SDC_index
"