We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
When addressing an (external) flash by a RTOS task, is it generally safe to allow that task to be preempted while it is updating the flash? What about interrupts during writing to flash?
I understand. I am more worried about operational sequences not getting completed at the low-level device domain, because the respective task is preempted. is that a danger? if not, I understand that if I use a task to access the flash (and that task only), and that task uses data that copied for it into a queue as source (the task is the only one reading the queue), no problem should be expected, even if interrupts occur as well as preemptions?
Whether or not there is a danger of
operational sequences not getting completed at the low-level device domain
depends on what kind of interface your external flash has. If the access protocol has maximum times between steps, preemption may have to be forbidden. Some interfaces (e.g. synchronous serial) may not care at all.
thanks. I guess I'll have to try and see, because the data sheet does not say a thing about it.
You must safeguard the portion of the code when it is performing a write to the flash. Else, the preempting will corrupt the data on the flash. I have experienced this first-hand when I wrote a embedded Linux NAND flash driver. Basically, the NAND flash eventually will hit a critical period when other devices generates interrupts, preempting in the middle of the flash write. This causes the flash's internal logic to provide some error correction. As a result, a few bits are modified and hence, your data is corrupted. You should mask out interrupts during this flash write period.
Cheers and good luck, Tom