How to set Keil compiler environment v1.0

Similar documents
Migrating from Keil µvision for 8051 to IAR Embedded Workbench for 8051

Application Note 606 Configuring Keil PK51 Tools to Support 24-Bit Contiguous Addressing Mode

MPLAB C1X Quick Reference Card

Migrating from Keil µvision for 8051 to IAR Embedded Workbench for 8051

QUIZ How do we implement run-time constants and. compile-time constants inside classes?

Megawin 8051 OCD ICE

Special Topics for Embedded Programming

Chapter 10. Programming in C

C Language Programming

NEW CEIBO DEBUGGER. Menus and Commands

Introduction to C++ with content from

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Tokens, Expressions and Control Structures

Topic 10 10/24/2010. C with Embedded Extension

EL6483: Brief Overview of C Programming Language

ELEG3924 Microprocessor

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

CMPE-013/L. Introduction to C Programming

BLM2031 Structured Programming. Zeyneb KURT

Embedded Controller Programming 2

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

A Fast Review of C Essentials Part I

real-time kernel documentation

EL2310 Scientific Programming

Programming (1.0hour)

Program SoC using C Language

805xRTOS. Generated by Doxygen 1.6.3

Basic Types, Variables, Literals, Constants

80C51 Block Diagram. CSE Overview 1

Declaration Syntax. Declarations. Declarators. Declaration Specifiers. Declaration Examples. Declaration Examples. Declarators include:

ET156 Introduction to C Programming

Short Notes of CS201

Interrupt Programming

CS201 - Introduction to Programming Glossary By

IAR Embedded Workbench for 8051 Version 7.30A

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Pragma intrinsic and more

INTRODUCTION 1 AND REVIEW

HOW TO DIVIDE BOOT AND FLASH AREAS

How to use the CIC61508 Secure SPI Mode Applets Concept PRELIMINARY CIC61508, V0.9,

Programming in C++ 4. The lexical basis of C++

Holtek C and ANSI C Feature Comparison User s Guide

TMS470 ARM ABI Migration

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Ch. 11: References & the Copy-Constructor. - continued -

Advanced Pointer & Data Storage

RL78 Development Environment Migration Guide

CET360 S12 DEMO PROGRAM #1 (C)

Computer Systems Lecture 9

This chapter introduces how to use the emulator of TOPICE quickly.

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

Programming the 8032 MCU Core

EE475 Lab #3 Fall Memory Placement and Interrupts

Using Keil Development Tools with Triscend FastChip and the E5 CSoC Family

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

C Programming Review CSC 4320/6320

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

ensures that the assembler generates instructions for the C167 (as opposed to XC167) Memory models The system startup file

M16C/62 APPLICATION NOTE. Using the Expanded Memory Mode with the M16C/ Abstract. 2.0 Introduction. 3.0 Memory Expansion Mode

C167 (as opposed to C166, C164) - Compiler dependent; KEIL C166 tool chain uses a. generates instructions for the

Lecture 6. Assembler Directives

High Performance Computing and Programming, Lecture 3

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

CS Programming In C

C++ For Science and Engineering Lecture 27

CS429: Computer Organization and Architecture

C Pointers. 6th April 2017 Giulio Picierro

Data Structures Unit 02

Stream Computing using Brook+

Getting Started with µvision2. and the C51 Microcontroller Development Tools

Structures, Unions Alignment, Padding, Bit Fields Access, Initialization Compound Literals Opaque Structures Summary. Structures

Chapter 12. Microcontroller Application Development Tools

TASKING C166/ST10 Tool Chain v8.6r1 patch 3 RELEASE NOTE

Embedded System Design

5.Coding for 64-Bit Programs

C51 Primer. An Introduction To The Use Of The Keil C51 Compiler On The 8051 Family

Homework / Exam. Return and Review Exam #1 Reading. Machine Projects. Labs. S&S Extracts , PIC Data Sheet. Start on mp3 (Due Class 19)

Lecture 3. Variables. Variables

AN Philips LPC2000 CAN driver. Document information

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

Embedded Controller Programming 2

Embedded Systems. Input/Output Programming

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science

instructions aligned is little-endian

Contents of Lecture 3

CS241 Computer Organization Spring Data Alignment

What's in the software package

Getting Started and Creating Applications

Dynamic Data Structures. CSCI 112: Programming in C

CROSSWARE 7 V8051NT Virtual Workshop for Windows. q Significantly reduces software development timescales

Variables. Data Types.

C Language Programming

Introduction to 8051 microcontrollers

CHW 469 : Embedded Systems

Computer System and programming in C

AN526. Si4010 API ADDITIONAL LIBRARY DESCRIPTION. 1. Purpose. 2. Building an Application with Additional Library

Get Connected with USB on RX62N RX62N USB

TIP120-SW-42. VxWorks Device Driver. Motion Controller with Incremental Encoder Interface. Version 2.1.x. User Manual. Issue 2.1.

Transcription:

Application Note AN0008 - Revised 28, April 2013 How to set Keil compiler environment v1.0 1. Introduction This application note describes the Keil 8051 compiler environment setting for ABOV 8051 MCU when using C language. Keil is 3rd party compiler, ABOV do not provide it. The ABOV 8051 MCU has M8051EW mentor core and many useful peripheral I/O. If MCU does not have any program in code memory, it can t operate and use. The Keil supports 8051 ASM and C development tools and makes HEX file for MCU operating. We use these tools for MCU S/W development. It is very simple to set the Keil 8051 compiler environment. (Note: this document only supports MC96FB504 series.) 2. Environment setting description 2.1. New project First of all, you have a project to develop some code for 8051. If you don t have it, you make a new project. Project New Project. After making a new project, select device for target. Mentor Graphics Co. -> M8051EW. See Figure 2-1. Then you can configure target option. Figure 2-1. CPU select

2.2. Options for target setting In the options for target tap, set Memory Model, Code Rom Size and etc for MCU. See Figure 2-2. Figure 2-2. Options for target Memory Model: The memory model determines the default memory type used for function arguments, automatic variables, and variables declared with no explicit memory type. Code Rom Size: specifies the size of the program memory. Off-chip Code memory and Off-chip Xdata memory: specifies CODE and XDATA memory areas of target MCU. Example) Table 2-1. The setting option by the taget Target MCU Memory Model Code Rom Size MC96FB504 Small Large Off-chip Code Memory Start:0x0000 Size:0x1000 Off-chip Xdata Memory X Note ROM:4kB XRAM:X 2

2.3. Options for output setting In the options for output tap, decide the Name of Executable which is output filename and select the Create HEX File to make hex output file (in this figure, FB504_timer0_timer1.hex) See Figure 2-3 Figure 2-3. Options for output 2.4. Options for A51 setting In the options for A51 tap, don t select Define 8051 SFR Names in Special Function Registers because of using specific MCU definition such as MC96FB504.h. See Figure 2-4. Figure 2-4. Options for A51 3

2.5. Add Program Source Code Finally, in the project workspace, add your source code or make new program file. See Figure 2-5. Figure 2-5. Add source file 4

3. Program setting description 3.1. Startup.a51 define The startup.a51 file is 8051 assembly code provided by Keil that sets up the C environment. Start-up code is always necessary in C applications that run in an embedded environment in which there is no desktop-style operation system. The startup.a51 is generated when New Project is created, if you add startup.a51 file. There is check point that is memory size. In startup.a51 file, the memory size defines initialize RAM contents as 0. So programmer checks these parameters and has to modify them if not correct. Default memory size of startup.a51 is IDATALEN EQU 80, XDATALEN EQU 0H Example) Table 3-1. The values that define.a51 options for each a target IDATALEN XDATALEN Note MC96FB504 0C0H 0H RAM : 192B XRAM : 0B Note) for more detail, check memory section for start address and size on the datasheet. 3.2. Stack point Stack area is located in IDATA. Stack pointer initially has default 0x07. Keil compiler can change stack pointer value in IRAM area (0x00~0xff) according to variables size of IDATA used in C application. 3.3. Interrupt vector The interrupt vector is located in code address 0x00~0xff range, each address is 8xN+3, N=interrupt _number. Interrupt routines are declared as follows: void function_name(void) interrupt interrupt_number [using register_bank] In C application, the interrupt_number(=n) determines the interrupt vector address of the interrupt function. Example) N=14 (8x14+3=115 (73h: interrupt vector address)) void T1_INT_HANDLER(void) interrupt 14 { } 5

3.4. Setup ROM/RAM data in C 3.4.1. ROM data define In ANSI C, the const type qualifier is used to define and access objects that are constant and may not be changed. But In Keil compiler, variables declared with the const type qualifier alone are stored in the memory area (data, idata, xdata, and so on) associated with their definition. So variables you want to locate in ROM must be declared with the code memory type. Example) const char ROM_Table[ ] = { 1,2,3,4 }; code char ROM_Table[ ] = { 1,2,3,4 }; 3.4.2. RAM data define If you set up Memory Model Small variable in DATA at Project option, DATA (0x00~0xFF) can be used as default memory. If you set up Memory Model Large variable in XDATA at Project option, XDATA can be used as default memory. Accessing DATA memory is considerably faster than accessing XDATA memory. For this reason, you should place frequently used variables in DATA memory and less frequently used variables in XDATA memory. 6

3.5. Using bit variable All bit variables are stored in a bit segment located in the internal memory area of the 8051. Because this area that has 0x20~0x2f address is only 16 bytes long, a maximum of 128 bit variables may be declared within any one scope. But in C language, when using a bit field structure in a union, order of value stored in the bit fields is very important. First define bit is LSB and last define bit is MSB in structure. Some other MCU has different order of bit. See the Example 2). Example 1) bit runflag; runflag = 0; // bit variable can get 0 or 1 Example 2) //keil bit field map typedef struct { unsigned char b0:1; // LSB unsigned char b1:1; unsigned char b2:1; unsigned char b3:1; unsigned char b4:1; unsigned char b5:1; unsigned char b6:1; unsigned char b7:1; // MSB } BYTE_FIELD; /*==== BYTE ====*/ typedef union { unsigned char byte; BYTE_FIELD bits; // bit is keil keyword. So bit bits } TYPE_BYTE; Pos 7 6 5 4 3 2 1 0 bit 1 0 0 1 0 1 1 0 byte 0x96 // keil unsigned char tresb; TYPE_BYTE tt1; Table 3-2. The order of value stored ni the bit fields tt1.bits.b0= 0;tt1.bits.b1= 1;tt1.bits.b2= 1;tt1.bits.b3= 0; tt1.bits.b4= 1;tt1.bits.b5= 0;tt1.bits.b6= 0;tt1.bits.b7= 1; tresb=tt1.byte; // Tresb = 0x96 7