Versa 8051 MCUs TB102 – Using Versa 8051 Include Files Rev 1.0

How to Use Include Files for Versa 8051 MCUs

1 Introduction For /assemblers that do not allow long file names, the naming convention is as follows: This technical bulletin addresses the include files developed for each of Ramtron’s fast and flexible AAFFDDDD.EXT Versa 8051 . Include files contain code AA: The initials of the or assembler, such as for the MCU’s special function registers (SFRs). This ML for the MetaLink Cross Assembler. code is compatible with most popular 8051 compilers and assemblers. FF: The family of the target device: RS for the Versa 8051 family. 2 Supported Compilers DDDD: The first digit grouping of the device name, for Currently, include files exist for the following 8051 example the VRS51L2070 will use 2070. compilers and assemblers: EXT: The extension for the target programming language, such as .H for the language, or .inc for an • MetaLink Macro Assembler assembler. • RIDE 51 (RKit) MA51 Macro Assembler • RIDE 51 (RKit) RC51 C Compiler 3.2 Location and Installation • Keil µVision3 A51 Macro Assembler All the files are placed in a zipped folder labeled with • Keil µVision3 C51 C Compiler the device name (for example, VRS51L3074.ZIP). • SDCC (Small Device C Compiler) When downloaded, the necessary file(s) can be moved • ASX8051 cross assembler to two possible locations:

If you are using a different compiler, apply one of the • The compiler/assembler source directory provided files as a template or contact Ramtron for • The folder of the current project assistance. (Any 8051 compiler or assembler that can Consult the compiler’s user guide for where it stores its produce output in the Hex file format can be used include files. with a Ramtron Versa 8051 MCU.) 4 Using the Files 3 About the Files To refer to a SFR definition, the appropriate “include” command must be present at the top of the file. 3.1 Naming Conventions

The file name consists of the compiler/assembler used 4.1 The #include Statement (C) and the device the file is intended for: The C programming language uses the #include directive to import functions and variable names. PART_COMPILER.EXT #include will have different syntax, depending on where the include file was placed. PART: The target device’s part number, such as VRS51L3074. If the file was placed in the same directory as other compiler source files, i.e. STDIO.H, use angle COMPILER: The name of the target brackets: compiler/assembler, such as Keil (short for Keil µVision3). #include EXT: The extension for the target programming If the file was placed in the same directory as the other language, such as .H for the C language or .inc for an source files, double quotes must be used: assembler. #include “VRS51L2070_SDCC.h”

Ramtron International Corporation ♦ http://www.ramtron.com 1850 Ramtron Drive Colorado Springs ♦ MCU customer service: 1-800-943-4625, 1-514-871-2447 x 208 Colorado, USA, 8092 ♦ 1-800-545-FRAM, 1-719-481-7000 Page 1 of 3 TB102 – Versa 8051 MCUs

4.2 The $INCLUDE Statement (Assemblers such 4.6 SFR Page as Keil MA51) Ramtron’s VRS51L2070 and VRS51L3074 MCUs have more registers than addresses. Therefore, a paging Most assemblers use the command to $INCLUDE system was developed: Registers that can only be access include files. used on page 0 must have DEVMEMCFG bit 0 set to $INCLUDE (VRS51L3074_RIDE.inc) 0. Registers that can only be used on page 0 must have DEVMEMCFG bit 0 set to 1. The abbreviation $IC can be used as well. Consult the specific assembler’s manual for more details. Accidentally referring to an SFR on the wrong page can cause unexpected results. For this reason, make 4.3 The .include Statement (Assemblers such as sure the page is set correctly before accessing SFRs ASX8051) that are defined for only one page.

Some assemblers use .include to access include 4.7 Inline Assembler (SDCC) files. Currently, the only assembler supporting this SDCC allows ASX8051 assembler code placed within syntax is the ASX8051 Cross Assembler. C code (inline assembler). When accessing SFRs from .include ‘VRS51L2070_ASX8051.inc’ inline assembler, it is not recommended to include the ASX8051 include file. Use the SDCC include file Consult the assembler’s manual for more details. instead and precede every SFR to be accessed with an underscore. For example: 4.4 Multiple Inclusion Prevention #include “VRS51L2070_SDCC.h” The provided include files have been protected using void function(unsigned char q) conditional preprocessor macros to prevent { compile/assemble errors when including the file more _asm than once. For instance, in C, the following might nop occur: inc _P0 ; Correct way of accessing P0 from inline assembler #include _endasm; P0++; // Standard way of accessing #include “AnotherFile.h” P0 from C code If AnotherFile.h contains #include } , the compiler will not For more information, consult the SDCC compiler user generate an error. guide. Some assemblers, such as the MetaLink Cross Assembler, do not have conditional processing. In this 5 Environment Settings case, the circumstances above would generate an It is recommended to use the following setup error. For these assemblers, use Ramtron include files parameters for error-free compiling/assembling. Always only once per file. try to use the current settings before modifying compile options. For more information, consult the 4.5 Register Access compiler/assembler user manual. Ramtron 8051 MCUs reserve addresses 080h to 0FFh 5.1 Keil µVision3 A51 Macro Assembler for SFRs. Not all SFR addresses refer to a valid SFR. Accidentally referring to an undefined SFR can cause From the Project menu, select “Options for Target”. On unexpected results. For this reason, only access SFRs the A51 tab, uncheck “Define 8051 SFR names” that are defined in the include file for that device. because the name list is incomplete and will generate errors.

www.ramtron.com Page 2 of 3

TB102 – Versa 8051 MCUs

In the include paths edit box, type the path where the names. A path such as “C:\MetaLink include files are placed or browse by clicking “…”. This Assembler\Include” will generate assemble errors. Use eliminates the need for the full path when using the a path such as “C:\MetaLink\Include”. $INCLUDE statement (see Section 4.2 for more details). 5.4 RIDE (RKit) MA51 Macro Assembler Make sure the option “Define symbols for the 8051 5.2 Keil µVision3 C51 C Compiler function registers” is unchecked (this option is off by From the Project menu, select “Options for Target” and default), because the name list is incomplete and will click on the C51 tab. generate errors. In the include paths edit box, type the path where the This checkbox is located deep within the settings. include files are placed or browse by clicking “…”. This Select “Tools” from the “Options” menu. Select “MA51” allows for typing angle brackets when using the from the list box and click “Edit”. On the next dialog, #include statement (see Section 4.1 for more click the “Advanced” button. In the dialog that follows, details). click on “Source” from the MA51 tree. The checkbox will now appear on the right side. 5.3 MetaLink Cross Assembler The MetaLink Cross Assembler only understands paths in the 8.3 file format, including for directory

Disclaimers RIGHT TO MAKE CHANGES Ramtron International Corporation, "Ramtron", reserves the right to make changes to its products - including circuitry, software and services - without notice at any time. Customers should obtain the most current and relevant information before placing orders. USE IN APPLICATIONS Ramtron assumes no responsibility or liability for the use of any of its products, and conveys no license or title under any patent, copyright or mask work right to these products and makes no representations or warranties that these products are free from patent, copyright or mask work right infringement unless otherwise specified. Customers are responsible for product design and applications using Ramtron parts. Ramtron assumes no liability for applications assistance or customer product design. LIFE SUPPORT Ramtron products are not designed for use in life support systems or devices. Ramtron customers using or selling Ramtron’s products for use in such applications do so at their own risk and agree to fully indemnify Ramtron for any damages resulting from such applications. DEBUGGING Ramtron provides its debug tools for the sole purpose of working with the customer’s own circuitry, software and services. Any attempt to copy, disclose, disassemble, or reverse-engineer Ramtron’s circuitry, software and services, a customer’s circuitry, software and services, or a third party’s circuitry, software and services, without prior consent is not permitted by Ramtron or by its associates. Ramtron assumes no responsibility for damages caused by any attempt to copy, disclose, disassemble, or reverse-engineer circuitry, software or services.

Copyrights • MetaLink 8051 Cross Assembler Copyright © 1989 by MetaLink Corp • µVision3 Copyright © Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2005 • RKit Copyright © 2001-1995 Raisonance SA • SDCC is subject to the GNU General Public License http://www.gnu.org/copyleft/gpl.html

www.ramtron.com Page 3 of 3