Author Topic: FLASH memory  (Read 11135 times)

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3237
    • View Profile
    • uTasker
FLASH memory
« on: December 02, 2007, 12:54:46 AM »
Hi All

Here is a short report on first experiences with the FLASH memory when porting the uFileSystem to the new LM3S6xxx project.

This demo is now on-line at so please visit it. It supports the standard uTasker demo project including
email test.

Comments welcome!



FLASH memory

The LM3S6965 has 256k of internal FLASH memory. The memory is used for program code and for the uFileSystem. Its granularity of 1k is fairly good, making file system work very easy. It also allows protection of 2k blocks against being read using a debugger or against erasure and programming. Since the protection can be set only once and then never removed, I didn’t try testing it – it is however there for hyper-sensitive users who want to be able to one-shot their code to the device so that it can never be read if falling in to the hands of their competitors.

The actual FLASH size available on the chip can be determined by reading the DC0 (Device Capabilities) register.

The only thing to be respected when using the FLASH is that it has to be written using aligned long words and deleted at 1k boundaries. Bits within a long work can individually be programmed to ‘0’, which makes it very flexible.

The programming is extremely simple: set the address to be modified to the FMA register; set the long word to be written to the FMD register and then command it using the FMC register. Wait about 50us (polling the FMC register to see when it is ready) and then do the next job.

1k page erasure takes about 25ms following more or less the same procedure, whereby no data has to be set.
The only other configuration required is to set the USECRL with the correct microsecond value to suit the present operating frequency.

It was thus not that complicated to set up the uFileSystem to operate together with the LM3S6965. I chose a 160k file system size with 2k parameter swap blocks for safely saving updatable user parameters and 156k uFileSystem file space with a 4k file granularity.

One thing which was not clear was whether the FLASH can still be accessed during program and erase operations. The data sheet doesn’t seem to specifically mention this although in the Luminary Micro forum someone states that it is there somewhere. So I played safe and copied the FLASH routines to SRAM and executed then there with protection against interrupts. Once everything seemed to be working correctly I then had a shot of simply running the routines from FLASH without any protection. Normally it will immediately crash if the whole FLASH memory is not available for reads during the operation, but the code seemed to work. So I have left it just like that until some problem is experienced or I can verify that this technique is advised.

With the uFileSystem operational, the HTTP and FTP servers could be activated and files loaded. In addition some other things like DNS, NetBIOS, HTTP POST, Time Server and SMTP were activated, giving a code size or around 31k – just a bit short of the IAR Kick Start limit of the compiler/debugger I am playing with. This was put on line to get an idea of its stability – visitors can command a welcome email from the device and play around with various controls and configurations.

« Last Edit: March 06, 2009, 01:45:13 PM by mark »