Sandro
Well-known member
Hi all,
reading SerialFlash official description I undestand that I can read the flash chip while erasing a (createErasable) file without any interruption; but (anyone know if) is there any possibility to write a file without interruption while erasing another file? This should be a very important feature in order to realize a LIFO file-area on a flash chip for my audio project.
I created (createErasable) a bunch of 1packet (64KB) files: file_0, file_1 and so on; a file-write function is called inside an AudioStream-class object. I verified that write process is interrupted when a file_x.erase function is called: and it is interrupted by the erase call even if erase is called in the main/Arduino code.
The eraseBlock function (called once by erase function) seems (to me) to be executed within __disable_irq() and __enable_irq(), since audio interrupt does not stop it... But in the official code (see below) there is nothing about it ... So the audio-interrupt should suspend it!!
Maybe the solution could be found by explicitly suspending the erase command execution while audio-interrupt is active... I guess is this the right way?
Thanks in advance for any suggestions..
reading SerialFlash official description I undestand that I can read the flash chip while erasing a (createErasable) file without any interruption; but (anyone know if) is there any possibility to write a file without interruption while erasing another file? This should be a very important feature in order to realize a LIFO file-area on a flash chip for my audio project.
I created (createErasable) a bunch of 1packet (64KB) files: file_0, file_1 and so on; a file-write function is called inside an AudioStream-class object. I verified that write process is interrupted when a file_x.erase function is called: and it is interrupted by the erase call even if erase is called in the main/Arduino code.
The eraseBlock function (called once by erase function) seems (to me) to be executed within __disable_irq() and __enable_irq(), since audio interrupt does not stop it... But in the official code (see below) there is nothing about it ... So the audio-interrupt should suspend it!!
Code:
void SerialFlashFile::erase()
{
uint32_t i, blocksize;
blocksize = SerialFlash.blockSize();
if (address & (blocksize - 1)) return; // must begin on a block boundary
if (length & (blocksize - 1)) return; // must be exact number of blocks
for (i=0; i < length; i += blocksize) {
SerialFlash.eraseBlock(address + i);
}
}
void SerialFlashChip::eraseBlock(uint32_t addr)
{
uint8_t f = flags;
if (busy) wait();
SPIPORT.beginTransaction(SPICONFIG);
CSASSERT();
SPIPORT.transfer(0x06); // write enable command
CSRELEASE();
delayMicroseconds(1);
CSASSERT();
if (f & FLAG_32BIT_ADDR)
{
SPIPORT.transfer(0xD8);
SPIPORT.transfer16(addr >> 16);
SPIPORT.transfer16(addr);
}
else
{
SPIPORT.transfer16(0xD800 | ((addr >> 16) & 255));
SPIPORT.transfer16(addr);
}
CSRELEASE();
SPIPORT.endTransaction();
busy = 2;
}
Maybe the solution could be found by explicitly suspending the erase command execution while audio-interrupt is active... I guess is this the right way?
Thanks in advance for any suggestions..