# Basic Internal Flash 1.4

## Purpose

This basic demonstrates the features of the Embedded Flash Controller (EFC) present on Atmel AT91 microcontrollers. The EFC enables in-application programming of the internal flash, as well as protecting memory regions or the whole chip.

## Hardware Requirements

This program can be used with the following evaluation kits:

- AT91SAM7S-EK
- AT91SAM7SE-EK
- AT91SAM7X-EK
- AT91SAM7XC-EK
- AT91SAM7L-EK
- AT91SAM7L-STK
- AT91SAM9XE-EK

## Description

The program performs the following set of commands:

- First, it unlocks the whole flash
- It writes a pattern in the last page of the flash, and checks it back
- It locks the last region of the flash, and verifies that the status is updated accordingly
- It unlocks the last region and verifies that it the status is updated accordingly
- Lastly, GPNVM #1 is cleared and set, the status being checked for update between the operations (the original state of the GPNVM is restored after this step)

## Usage

1. Build the program and download it inside the evaluation board. Please refer to the SAM-BA User Guide, the GNU-Based Software Development application note or to the IAR EWARM User Guide, depending on your chosen solution.
2. On the computer, open the DBGU port with a terminal application (e.g. HyperTerminal on Microsoft Windows).

- Settings: 115200 bauds, 8 bits, 1 stop bit, no parity, no flow control.

3. Start the application.
4. The application will display the various tests it is executing and the results (example shown for the SAM9XE256):

   > `-- Basic Internal Flash Project 1.4 --
   > -I- Unlocking the whole flash
   > -D- Actual lock range is 0x200000 - 0x240000
   > -I- Writing last page with walking bit pattern
   > -I- Checking page contents .....................................................
   > ........................................................................... ok
   > -I- Locking last page
   > -D- Actual lock range is 0x23C000 - 0x240000
   > -I- Checking lock status ... ok
   > -I- Unlocking last page
   > -D- Actual lock range is 0x23C000 - 0x240000
   > -I- Checking lock status ... ok
   > -I- GPNVM #1 is cleared
   > -I- Setting GPNVM #1
   > -I- Clearing GPNVM #1
   > -I- All tests ok
   > `

###### Atmel Corporation ©2008