Writing to Internal Flash on Fez Cerb persists only on first write

@ Brett - I’ve tested for 600 reads and it’s almost instant :smiley: , although I’ve hit another stumbling block, I’ve tested the “Eraseblock” function but am getting an exception “An unhandled exception of type ‘System.Exception’ occurred”, I can’t see what the issue may be, I’ve replaced all “CR.Write” with “CR.SetBits”. The code fails at the first “CR.SetBits(cr);” call.

public static void EraseBlock()
        {
            byte Sector = 11;
            /*  0-2  : 16 16 16             Bootstrap 48K   
             *  3    : 16                   Configuration 16K
             *  4    : 64                   Code : 64K
             *  5-8  : 128 128 128 128      Code2 : 512K
             *  9-11 : 128 128 128          Deployment: 384K
             */

            UnlockFlash();
            
            // enable erasing
            uint cr = Sector * FLASH_CR_SNB_0 | FLASH_CR_SER;
            CR.SetBits(cr);

            // start erase
            cr |= FLASH_CR_STRT; // 0x00010000;
            CR.SetBits(cr);

            // asure busy flag is set up (see STM32F4 errata)
            CR.SetBits(cr);

            // wait for completion
            while ((SR.Value & FLASH_SR_BSY) != 0)
            {
                System.Threading.Thread.Sleep(10);
            }
            LockFlash();
        }