Jump to content
43oh

CC3200: Interrupts and write flash memory with SLFS lib


Recommended Posts

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);

 

Link to post
Share on other sites

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

Link to post
Share on other sites

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.)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...