Keil Logo

Pre-Download Scripts

Pre-download scripts are files that contain commands and instructions to prepare the device for Flash programming. The commands are executed prior to downloading the application to Flash. For example, the file can include commands to:

The file name can be entered into the field Options for Target — Utilities — Init File

Configure memory bus

The memory interface can be configured using predefined functions (for example, _WBYTE or _WDWORD) that write to the target memory. Use these functions in pre-download scripts. Some devices require an interface to be configured prior to accessing attached devices. Typically, this is true for external Flash ROM devices. For example:

_WDWORD(0xFFE00000, 0x20003CE3);   // BCFG0: Flash Bus Configuration
_WDWORD(0xE002C014, 0x0E6001E4);   // PINSEL2: CS0, OE, WE, BLS0..3

Functions can use the Configuration Wizard syntax to create a menu-driven configuration file:

/***********************************************************************/
/*  FLASH.INI: Flash Initialization File                               */
/***********************************************************************/

//*** Use Configuration Wizard in Context Menu ***

FUNC void Setup (void) {

// External Memory Controller (EMC)
//   Bank Configuration 0 (BCFG0)
//     IDCY: Idle Cycles (0-15)
//     WST1: Wait States 1 (0-31)
//     WST2: Wait States 2 (0-31)
//     RBLE: Read Byte Lane Enable
//     WP: Write Protect
//     BM: Burst ROM
//     MW: Memory Width  0=8-bit  1=16-bit
//                       2=32-bit 3=Reserved
//
  _WDWORD(0xFFE00000, 0x20003CE3);   // BCFG0: Flash Bus Configuration

  _WDWORD(0xE002C014, 0x0E6001E4);   // PINSEL2: CS0, OE, WE, BLS0..3
                                     //          D0..31, A2..23, JTAG
}

Setup();                             // Setup for Flash

Load program objects

Program objects, which are needed in addition to the user application, can be downloaded through the command LOAD using a pre-download script. For example:

LOAD MyFile.HEX

Note

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.