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
sam0 flashpage: wait for READY bit in INTFLAG after write command #10880
Conversation
From datasheet also:
|
As an additional information: I've put also a counter inside that while to see if it gets indeed triggered and for how much time. On my saml21-xpro for the main flash it usually passes inside just once, for the RWWEE about 300 times. So while for main flash it doesn't seem to be somehow vital, for RWWEE it seems to be. Anyhow given it's in the specs it may be still wise to always use it probably. |
This is a bit weird, isn't it ? I mean, according to the datasheet this is supposed to be the same flash but smaller. I'll try to test your PR on SAML21 and SAML10/SAML11 soon. I'll also check with different wait states to see if there is a difference but I'll be quite busy this week. Anyway, I agreed with you. This check must be there even "if it works" now. |
I was quite surprised by the difference (almost instant vs 300) I must admit! While I don't know how it is internally managed, I could try to explain to myself the difference by the fact that the RWWEE must have a quite more complex logic (to handle this "read while write" thing, so must somehow be allowing the main flash to be reading at the same time if needed) or also by the fact that the main flash has a cache while this one not. |
Something else I noticed in the SAMD manual.
That raises the question whether we should worry about the INTFLAG.READY bit for any CMDEX command, including PBC. |
Have a look at the nvm driver in ASF, BTW. I suggest we create a static inline function that waits for the ready bit. That way there is only one place where we need the |
For example
And to use it:
|
Thanks for the hint, that looks good! I would even put the while then in the inline so it becomes even cleaner maybe, try to check my lastest commit. I also added the wait after PBC as you suggest as the ASF does. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested lastest changes on SAML10-XPRO.
You have my ACK too.
Contribution description
While debugging on an issue with RWWEE (see devel mailing list) I saw in the SAML manual:
And noticed that the last point, waiting for the READY bit in INTFLAG, was actually missing in current code (while it is done correctly for example for the erase cycle).
While I didn't notice myself any problem until now with the code without this READY bit waiting, I believe it may be more correct to add this code and prevent possible race conditions and strange errors.
Testing procedure
On SAMx boards you can run the automated test in tests/periph_flashpage.