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

Library does not work with Feather M4 Express and Adafruit_SleepyDog-master #37

Open
Casey10110 opened this issue Dec 4, 2019 · 1 comment

Comments

@Casey10110
Copy link

Casey10110 commented Dec 4, 2019

I was having trouble localizing a problem before with the SPIFlash library and finally pinned it down to its interaction with the SleepyDog library. I created a minimal example which basically causes SPIFlash writes to corrupt the file system (see attached). This example works when you comment out the Watchdog.sleep(1000); ... to reproduce the error, follow these steps, first with that line commented out:

  1. format the M4 Express using the SdFat_Format example
  2. run the minimal example attached
  3. run the SdFat_OpenNext example to see what was written

Then repeat that with the Watchdog.sleep(1000); line and watch the file system become corrupted. Any ideas what in the SleepyDog library is causing this?

Flash_Memory_Problem_Minimal_Example.txt

Update: this same crash happens when using CircuitPython to create the file system and see what is written.

@Casey10110
Copy link
Author

Casey10110 commented Dec 5, 2019

Adding

OSCCTRL->DFLLVAL.reg = OSCCTRL->DFLLVAL.reg;
while( OSCCTRL->DFLLSYNC.bit.DFLLVAL );

after sleeping seems to fix the problem. Basically, some of the configuration done in startup.c is apparently lost when the SAMD51 goes to standby. The only reason I thought to look at this is because I noticed that sleeping also changed the pitch of a physical oscillator (a change of about 230 cents) I have connected to the device ... so I assumed it was changing the timers' configuration. Looking at wiring.c and startup.c, I localized an area of code that appeared to re-configure it properly after sleep. In all honesty, I have no idea what it does, but it seems to fix both problems. Any clues as to why this works?

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

No branches or pull requests

1 participant