Marzogh / SPIMemory

Arduino library for Flash Memory Chips (SPI based only). Formerly SPIFlash
http://spimemory.readthedocs.io/en/latest/
GNU General Public License v3.0
430 stars 136 forks source link

Bug report - readByteArray fails at some addresses but no in a loop. #219

Open spinalcode opened 3 years ago

spinalcode commented 3 years ago

Bug Report

Describe the bug

When trying to read data from specific address I get 0x0D error, but not always.

To Reproduce

Provide a minimal code snippet example that reproduces the bug (If you're using one of the examples that came with the library, just tell us which one instead of pasting the entire example's code). Please make sure you wrap any code in the proper code blocks like below

/* This works perfectly */
void loadScreenFromFlash(){
  uint16_t lineBuffer[240];
  uint8_t lineBuffer8[240];
  for(int y=0; y<240; y++ ){
    if (flash.readByteArray(y*240, lineBuffer8, 240,1)) {
     for(int x=0; x<240; x++){
        lineBuffer[x] = pgm_read_word(&brain_pal[lineBuffer8[x]]);
      }
      //lcd.drawImage(0,y,240,1,lineBuffer);
    }
  }
}

/* This fails when y >= 137 with 0x0D error (4bit alignment) */
void loadLineFromFlash(int y){
  uint16_t lineBuffer[240];
  uint8_t lineBuffer8[240];
  if (flash.readByteArray(y*240, lineBuffer8, 240,1)) {
   for(int x=0; x<240; x++){
      lineBuffer[x] = pgm_read_word(&brain_pal[lineBuffer8[x]]);
    }
    //lcd.drawImage(0,y,240,1,lineBuffer);
  }else{
    Serial.print("Failed to load line ");
    Serial.print(y);
  }
}

Expected behavior

flash.readByteArray to work the same in both functions above

Screenshots

If applicable, add screenshots to help explain your problem.

Wiring diagram

If applicable, add a wiring diagram to help explain your problem.

Software environment (please complete the following information):

Additional context

Add any other context about the problem here.


DO NOT DELETE OR EDIT anything below this

Note 1: Make sure to add all the information needed to understand the bug so that someone can help. If any essential information is missing we'll add the 'Needs more information' label and close the issue until there is enough information.

Note 2: For support questions (for example, tutorials on how to use the library), please use the Arduino Forums. This repository's issues are reserved for feature requests and bug reports.


GitHub issue state GitHub issue title GitHub issue author GitHub issue label GitHub issue comments GitHub issue age GitHub issue last update