Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Version published after converting to the new editor


An alternative to writing applications that use the FlashPro-ARM DLL, some programming sequences can be written using a script file. A script file is a text file with basic syntax that can execute all buttons available, and has rudimentary flow control such as IFs and GOTOs. Generally, buttons available on the main dialog can be used in the script file; however, other options available on screens like memory options, serialization etc., can only be changed by loading a different configuration file. A typical script file will start by loading a configuration file and code file, followed by Auto Program and an IF statement to test Auto Program result to decide what happens afterwards.
The script file can be selected in the GUI, or appended as a parameter for the FlashPro-ARM executable (usually used to create shortcuts that call a specified script file right away):

...


The "Script" button is the dynamically programmable device action button that takes a selected script file and executes it. The Script button has a name "Script – none" (Figure 10.1) if the script file is not defined or Script: <script file> when the script file is selected (Figure 10.2). When the Script button is pressed and the script file not defined, the Open File dialog will be used to select a script file. When the Script file button is pressed and the script file is defined, the script till be executed. After that, a new script file can only be loaded using the pull down menu FileOpen Script File.
The Script button is very useful for implementing a short programming sequence not present directly in the Device Action group buttons. Below is a sample script used for downloading two different code files to a target device - first code used for hardware test, and second code is the final user code. The same sequence

Anchor
_Toc452148569
_Toc452148569
Figure 10.1: Script file not defined.
Anchor
_Toc452148570
_Toc452148570
Figure 10.2: Script file active. can be used with other buttons. Using a text editor create a script file and save it as a file, for example, "test.sf" or any other file name. See this chapter below for all available instructions that can be used in the script file. The install directory contains a "script" folder with prepared scripts that show how to use most functions.
;--------------------------------------------------------------------------
; easy script file;
;--------------------------------------------------------------------------
LOADCFGFILE C:\Program Files (x86)\Elprotronic\ARM\FlashPro-ARM\test.cfg
LOADCODEFILE C:\Program Files (x86)\Elprotronic\ARM\FlashPro-ARM\code.txt
AUTOPROGRAM
IF FAILED GOTO finish
; now the hardware is tested according to downloaded firmware
MESSAGEBOX YESNO
"Press YES when the test finished successfully."
"Press NO when the test failed."
IF BUTTONNO GOTO finish
LOADCFGFILE C:\Program Files (x86)\Elprotronic\ARM\FlashPro-ARM\final.cfg
LOADCODEFILE C:\Program Files (x86)\Elprotronic\ARM\FlashPro-ARM\code.txt
AUTOPROGRAM
>finish
END
;--------------------------------------------------------------------------
The script file above loads the first configuration file and the first code file into the programmer's data structures. The Auto Program function will flash the selected code file into the selected MCU based on given configuration settings. If the wrong MCU is selected, Vcc too low, or any of the Auto Program features fail, then the function will not succeed. The user can insert an "IF DONE" or "IF FAILED" line to interpret the Auto Program result. The script file then follows with a message box that lets the user decide if the final code should be programmed. If NO is clicked, the GOTO statement will jump to the "finish" label denoted by the special character ">". Some users add protection settings to disable debug access in the final Auto Program configuration to protect their code from end-user access, the specifics of which depend on the target MCU.
Before running the script file the configuration files named test.cfg and final.cfg required in the setup should be created using the GUI software first. To do that connect target devices to programming adapter, select desired configuration and save the configuration file as test.cfg and create final configuration file in a similar way.

...