您好,欢迎光临本网站![请登录][注册会员]  
文件名称: Infineon-XMC1000-C_Start_and_Device_Initialization-AN-v01_00-EN启动文件说明.pdf
  所属分类: C
  开发工具:
  文件大小: 711kb
  下载次数: 0
  上传时间: 2019-09-01
  提 供 者: ferg*****
 详细说明:介绍了DAVE环境下XMC1000的启动文件;本应用文档是英飞凌官方提供的介绍XMC1000的启动过程和器件初始化的文档;对英飞凌单片机器件底层驱动文件提供了更深刻的了解!C-Start and device initialization infineon XMC1000 Introduction Introduction The purpose of this user guide /application note is to provide a broad overview of device initialization. This guide elaborates upon the various stages of initialization which includes boot-up from a state of reset, C-Start and application initialization 1.1 C-Start(also known as CStart/Startup) C-Start is essentially a set of activities that must be performed before giving control to the user applicatio entry point. A good example of an entry point is the"main" function Applications containing operating systems may potentially have an alternative entry point. 1.2 C-Start packaging In a few configurations, C-Start functionality is a part of the user application image. In others, C-Start and user applications are distinct images, such as the U-Boot bootloader for example. Most embedded systems however have the c-start functionality combined with the final application On-Chip firmware On-Chip firmware C-Start C-Start User application Single image Distinct images User application Figure l C-Start tasks There are two fundamental tasks c- Start is expected to perform they are Device initialization and any errata workaround implementation · Program loading These tasks are elaborated in subsequent chapters Application Note Revision 1.0 2016-02-22 C-Start and device initialization infineon XMC1000 C-Start tasks C-Start tasks This chapter elaborates upon the various tasks of c-start a cortex-Mo CPU-based xmc1000 device is used in the illustrations that follow. Code fragments have been taken from the following files available with the daveTm distribution startup_ XMC1200S · system_XMC1200.C 2.1 Device booting the CPU starts executing the startup software(SSW)stored in the ROM area of memory. The SSW execut/ ed The following diagram indicates that after the reset (either Power-On-Reset or System reset) has been released stage is indicated by the pulling-up of P0. 8. The role of the sSw is to evaluate the requested chip boot mode and take any necessarv actions As an example. if the chosen boot mode is ASC BSL mode, the sSw prepares to download the user application by first configuring the usic peripheral for io exchange and subsequently uploads the application into SRAM. The application is received over the UArt Io lines Reset released User application BootROM C-Start Entry point of user code routines application User application Figure 2 Booting stages By default, the SSW runs with Main Clock (MCLK frequency of 8 MHZ, and all peripherals are disabled However, some user applications may require starting up with a different system frequency or configuration of enabled peripherals. For this purpose, two SSw-related data locations in flash are made available at 1000 1010H and 1000 1014 respectively the code fragment below is an extract of the vector table written for the XMc1200 device Vectors long CLKVALI SSW / Clock configuration in Ssw long CLKVAL2 SSW / Peripheral confiquration in SSw * CLKVALl- SSW and CLKVAL2-_ SSW defined in the vector table point to the above mentioned flash addresses. The code fragment below shows the definition of both of them for the Xmc1200 device #define ClIVAl1 Ssw 0x00010400 #define CIIVAL2 SSW 0x80000000 These values can be changed directly in these definitions. These values will then be programmed to the respective addresses in flash when the application code is downloaded to the device In the Systemlnit( function called by the reset handler, the mClK frequency will be reinitialized to the maximum frequency, which is 32 MHz for XMc1100/ 1200/1300 devices and 48 MHz for the Xmc1400 device This is also the frequency at the point of user application entry Application Note Revision 1.0 2016-02-22 C-Start and device initialization infineon XMC1000 C-Start tasks If a user application is developed using DAVE T CE, a different start up system frequency can be configured through the clock_XMcl_0 APP(see section 5.2 The User Mode with Debug Enabled (UMD) is a commonly deployed boot mode On execution, the SSW reads the user application vector table typically placed at the start of the flash area. It then extracts the start address of the c-Start routines and relinquishes control to the reset handler routine The vector table on Cortex-M devices, as illustrated in the following figure, is basically a table of function pointers used to handle CPU exceptions and device interrupts. the second entry in this table contains the start address of the reset handler Application Stack Pointer Reset Handler Pointer EXception 1 Handler Pointer Exception2 Handler Pointer Figure 3 Cortex-M vector table syntax unified cpu cortex-mC section . reset align 2 globl ype Vectors, object Vectors long initial sp Top of stack */ Reset Handler /★ Reset Hand1ex* long 0 /大 Re served大/ Entry HardFault Handier / Hard Fault Handler * /* Other vector table entries * he code fragment listed above is an extract of the vector table written for the XMC1200 device for the gnu tooL chain.The function pointer Reset_ Handler is responsible for device initialization. The on-chip firmware gives control to this reset handler Attention: With the exception of the reset handler, all function pointer entries in the vector table have weak implementations in C-Start. The weakly defined CPU exception and device interrupt handler routines Application Note Revision 1.0 2016-02-22 C-Start and device initialization infineon XMC1000 C-Start tasks provide a default implementation. When users provide an alternative final implementation, these weak definitions are automatically overwritten 2.2 Device initialization The first stage of a typical reset handler written for an XMCl device(specifically, the XMC1200 )is shown below. Major functionality is highlighted in bold thumb func globl Reset Handler type Reset Handler, function Reset Handler / Initialize interrupt veneer * ldr rl, =eROData ldr r2, =Veneerstart ldr r3, -VeneerEd copy data /* Clock tree, external memory setup etc may be done here * ldr ro, =SystemInit It can be seen from the code fragment above that the reset handler invokes a function called Systemlnit(), which is responsible for clock tree initialization Note: Any user application claiming to conform to the CmSiS standard must invoke the CMSiS routine Systeminit( to perform device initialization Users are allowed to insert custom device initialization code in the listing above Attention: Device initialization related code must abstain from accessing global variables because at this stage, program loading is still pending. 2.3 Program loading Once the device initialization code is executed, control is given to the next stage of the reset handler, known as Program loading The job of a program loader ( also known just as loader,)is to prepare an environment suitable for user program execution A'C program typically has the following sections TEXT RO-DATA DATA BSS STACK HE Application Note Revision 1.0 2016-02-22 C-Start and device initialization infineon XMC1000 C-Start tasks USER DEFINED The job of the program loader is typically to copy TEXT, RO-DATA and DATA from their load addresses(Load Memory Area or LMA)to their run addresses(Virtual Memory Area or VMA) VMA is the address the various sections of the program are linked to LMA is the address that they are stored at The concepts of LMA and vma are elaborated on in a subsequent chapter in this document The start of LMA/VMa and length of a section to be relocated is obtained from the linker script file. The following is a code snippet of the program loader /*工 ni tia1 ize data* ldr r1,=DataloadAddr data start data end b1 copy data /★RAM ldr rlr ram code load ldr 2 ram code start r3,= ram code end b copy data / BSs section * # inde f SK工 P BSS CLEAR ldr 1 bss start ldr 2 bss end movs ro 0 subs r2, r1 ble .I loop done I loop subs #4 str 0,[r1,r2] b at 1o○p3 ne #endif SKIP BSS CLEAR */ #i fndef SKIP LIBC INIT ARRAY dr rO libc init array blx r0 #endif Application Note Revision 1.0 2016-02-22 C-Start and device initialization infineon XMC1000 C-Start tasks idr ro, =main bl / DATA COPY thumb func type copy data, function copy data subs r3, r2 ble L loop done , locp subs 3,#4 l dr r0,[r1,r3] str ro, [r2 r3] bat L lOOp bx Ir size Reset Handler, -Reset Handler The program loader shown above is for an application which must eXecute In Place(XlP). Data is copied from its lma in flash to the vma in sram BSS. Which has both lma and vma in sram. is cleared The resulting effect is that the global data variables are already in an initialized state when control is eventually relinquished to the user application The vector table is remapped to locations in SRAM, with each vector allocated to a size of 4 bytes. Typically, the allocated size is not sufficient for an exception or interrupt therefore a branch instruction is needed to jump to the actual handler at another location. this is achieved via veneers. Basically, a veneer acts as an intermediate target of the instruction and then sets the pc to the actual location the code extract below is an example of a veneer code section .XmcVeneerCode","ax"prcgbits a⊥1gn g⊥o⊥ ardfault veneer HardFault veneer LDR RO =HardFault handler MOV PC RO Application Note Revision 1.0 2016-02-22 C-Start and device initialization infineon XMC1000 C-Start tasks 2.4 Giving control to the user application entry point At this stage The device initialization is complete Application data has been relocated from lma to Vma The execution environment has now been correctly setup and it is time to relinquish control to the user application 's entry point. While this is typically the main() function for bare-metal programs, alternative entry points are possible /* CEDE CONTROL TO ENTRY POINT OF USER APPLICATION * ldr ro, =main blx ro The stack pointer is programmed with the value from the top of the stack, and the program counter is adjusted to enable the jump to main( routine Attention: An alternative application entry point can be programmed into the Program Counter register 2.5 Default definition of exception and interrupt handlers C-Start provides a default definition for each of the CPU exceptions and device interrupt handlers The default handlers do no more than implementing a self-looping program thumb fu weak Default handler type Default handler, function De fault handler Users may in their application provide an alternative implementation of each handler. When an alternative implementation is provided, the linker ignores the weak definition and instead considers the object file of the alternative definition for linking purposes / Example of interrupt handler definition in one of users c files: * void hardFault handler(void)( Application Note Revision 1.0 2016-02-22 C-Start and device initialization infineon XMC1000 Linker scripts Linker scripts 3.1 Role of a linker script This chapter elaborates upon the linker script implementation intended for Infineon's XMc devices using the GNU toolchain. Excerpts from linker scripts to be found in the free dave tool from Infineon are used in the llustrations that follow A linker script defines rules and constraints for the linker. The role of the linker is to assign Load and Run addresses to application code and data. 3.2 Memories on a typical XMCTM device Memory Usage Flash CoDE and Ro-data SRAM Any of CODE, Ro-DATA, DATA, BSS, Heap, Stack Figure 4 XMCTM memories and usage Concept of LMa and vma LMA(Load Memory Address) is the address where the program is physically stored VMA(Virtual Memory Address), also known as the Run address, is the address where the program is executed from Some examples are: Program can be stored on flash and executed from Sram Program can be stored and executed from flash Some parts of the program can be executed from flash while the rest from SRAM This concept is pictorially represented here: Load view Run view FLASH LMA Of code rodata VMA of coDe ro-DATA and data SRAM LMA of bss VMA of data and bss Stack, Heap Figure 5 LMA and VMA concept Application Note Revision 1.0 2016-02-22
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 输入关键字,在本站1000多万海量源码库中尽情搜索: