Yaro 1 Posted March 2, 2015 Share Posted March 2, 2015 Hi all, I've tryed SLFS library and works very well but I've have some problems with interrupts. I've created and opened file in setup. Now I put in the interrupt the function of file write but when interrupt occurs code stop working. Here's code: Setup: SerFlash.begin(); SerFlash.open("myfile.txt", FS_MODE_OPEN_CREATE(400000, _FS_FILE_OPEN_FLAG_COMMIT)); SerFlash.close(); SerFlash.open("myfile.txt", FS_MODE_OPEN_WRITE); pinMode(INT, INPUT_PULLUP); attachInterrupt(INT, IntFunction, FALLING); IntFunction: SerFlash.write(data); Quote Link to post Share on other sites
spirilis 1,265 Posted March 2, 2015 Share Posted March 2, 2015 I do not recommend using any of the API functions inside of an interrupt. This goes for just about any other API stuff, including any WiFi, Serial, Wire, etc. stuff. Use interrupts to set a global (declared "volatile") variable that you check in your main loop. Sent from my Galaxy Note II with Tapatalk 4 Quote Link to post Share on other sites
igor 163 Posted March 2, 2015 Share Posted March 2, 2015 It is usually okay to use functions having to do with interrupts (e.g. acknowledge interrupt, restore interrupt to previous value) inside interrupt handler. Likewise, reading or writing a few pins is probably okay. But as spirilis said, big heavy things are usually best left for the main program. (Though I have gotten away with using Serial print for debugging inside of interrupt handler on Stellaris LP.) Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.