Automatically Initializing Data Segment Values in MAX-IDE

[09-11 23:02:11]   来源:http://www.88dzw.com  单片机学习   阅读:8704

文章摘要:Automatically Initializing Data Segment Values in MAX-IDEAbstract: This application note discusses the code and data segment facility provided by MAX-IDE for applications programming on MAXQ® microcontrollers. The code and data segment mechanism provides a way to automatically declare variable l

Automatically Initializing Data Segment Values in MAX-IDE,标签:单片机开发,单片机原理,单片机教程,http://www.88dzw.com

Automatically Initializing Data Segment Values in MAX-IDE

Abstract: This application note discusses the code and data segment facility provided by MAX-IDE for applications programming on MAXQ® microcontrollers. The code and data segment mechanism provides a way to automatically declare variable locations in data memory and to initialize those variables with starting values. Application code can then be used to cache those variable values in flash memory and restore them as needed. This approach allows an assembly-based application to take advantage of the data segment autoloading provided by MAX-IDE, while still operating consistently whether or not the microcontroller is connected to a JTAG debugger. The MAXQ2000 microcontroller EV kit is used to demonstrate the method and code examples are provided in the text.

Overview

Variables in MAXQ assembly applications can be stored either in working registers (such as the accumulators A[0] through A[15]) or in data memory (SRAM). Storing variables in data memory provides a larger working area for the application variables, but does require additional access time.

The MaxQAsm assembler and MAX-IDE environment provide a mechanism to declare separate code and data segments, with a separate hex output file generated for each segment. At run time, MAX-IDE automatically loads the code segment file into program memory (typically flash) and the data segment file into data memory (typically RAM). However, as the data memory is volatile, the data segment contents will not remain intact once the microcontroller is powered off.

This application note uses the MAXQ2000 EV (evaluation) kit to demonstrate first, how to save these preloaded data memory values in flash during the initial application run, and then how to refresh the data segment values from flash when the microcontroller is subsequently powered on again. This two-step process allows the same data segment mechanism to be used to declare and initialize variables, whether the application is in development (connected to a JTAG adapter and MAX-IDE) or running in the field.

Demonstration code for this application note is written for the MAXQ2000 microcontroller and the MAXQ2000 EV kit, but the code and principles shown are applicable to any MAXQ20-based microcontroller with rewriteable program flash memory.

The latest installation package and documentation for the MAX-IDE environment are available for free download.
  • MAX-IDE installation
  • MAXQ Core Assembly Guide
  • Development Tools Guide

Variables and Storage Locations

Embedded applications typically require a certain amount of working space to store state information, configuration settings, intermediate working values, loop counters, and the results of calculations. Values stored in this working space are typically known as variables and share the following characteristics.
  1. They are temporary. They do not need to be saved if the application is interrupted by a power failure or reset.
  2. They are accessed and updated frequently. They must be stored in locations that can be read from or written to quickly; there must be no limit on the number of times to which the locations can be written.
  3. They often have defined initial values. The user’s code must set them to a particular value at the beginning of the application.

[1] [2] [3] [4] [5]  下一页


Tag:单片机学习单片机开发,单片机原理,单片机教程单片机学习
分类导航
最新更新
热门排行