Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with pageRead() #15

Open
battosai30 opened this issue May 2, 2016 · 6 comments
Open

Problem with pageRead() #15

battosai30 opened this issue May 2, 2016 · 6 comments
Assignees
Labels

Comments

@battosai30
Copy link

Hi,

I'm working on porting your library to Energia (MSP430 Arduino like IDE). Another point : it's a version E (not a D but what are the differences ?)

After very few changements, seems to be OK except one point : pageRead() does not work reading page 0.And I can't explain why ... It's ok this other pages or using pageToBuffer()+bufferRead().

@BlockoS BlockoS self-assigned this May 2, 2016
@BlockoS
Copy link
Owner

BlockoS commented May 2, 2016

I quickly looked at the dataflash e version datasheet. It seems they added some new continuons read modes, and maybe they fixed chip erase...
It also seems that page 0 is split in 2. I'll check it in more details tomorrow. I misread it. It's sector 0 not page 0 that is split in 2.

@BlockoS
Copy link
Owner

BlockoS commented May 3, 2016

I can't see why reading page 0 fails with pageRead...
The only difference with the pageToBuffer+bufferRead combo is the active wait.
Maybe this may help:

dataflash.waitUntilReady(); // Just to be sure. Maybe this should be added at the begging of pageRead
dataflash.pageRead(0, 0); 
for(size_t i=0; i<PAGE_SIZE; i++) // page/buffer size accessors should be added to the API...
{
    data = SPI.transfer(0xff);
}
dataflash.end();

Unfortunately I don't have any version E dataflash.

@battosai30
Copy link
Author

Thank you very much :)

You were right : dataflash.waitUntilReady() solved the problem. Another point : I noticed at the samed time that it works if the pageRead() loop is preceded by

Serial.print("The test = ");
dataflash.pageToBuffer(0, 1);
dataflash.bufferRead(1, 0);
Serial.print(SPI.transfer(0xff));
Serial.print(SPI.transfer(0xff));
Serial.println("");

To adapt you're library to msp430 I removed lines about Atmel SPI registers (could it cause that ?).

@battosai30
Copy link
Author

But the strange fact stay "why only on page 0??".
If I write and read on pages 1 to XXX => no problem
If I write and read on pages 0 to XXX => problem

@BlockoS
Copy link
Owner

BlockoS commented May 3, 2016

The Atmel SPI register stuffs are just here to flush any pending interrupts during initialization and to quickly setup SPI registers when we call begin() (in case of multiple SPI devices).

Have you tried doing a pageRead on let's say the second page, then on page 0 ?
I think page 0 fails because of some internal state stuffs. I didn't anything in the datasheet about some specific behaviours concerning page 0.
A way to verify this will be to issue a pageToBuffer followed by a pageRead on the same page, and a pageToBuffer with a pageRead on 2 different pages. If the first one fails and the second one succeds, this may mean that changing to a different page blocks until the operation on the current page is finished.

I feel ashamed because I realized that this issue is linked to the now 5 years old issue #5

@BlockoS BlockoS added the bug label May 3, 2016
@battosai30
Copy link
Author

Don't feel ashamed, your library help me a lot :) this kind of chip is not very difficult to understand, but there are lot of commands with a special protocol to respect, so it's a big deal to get a full working lib.

I tried this :

 dataflash.pageRead(0, 0);
    printSPI();
    dataflash.pageRead(0, 0);
    printSPI();
...
void printSPI() {

  int j = 0;
   byte data;
    do
      {
         data = SPI.transfer(0xff);
        if(data != '\0')
          Serial.write(data);
        ++j;
      } while((data != '\0') && (j < 64)); 

}

Result : the first pageRead(0,0) fails, but the second works. If I add a dataflash.waitUntilReady(), both work. As you suggest, I think it's an internal timing issue, something like an index which takes time to be reset ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants