low_level_init.c

来自「一个电表的程序」· C语言 代码 · 共 78 行

C
78
字号
/**************************************************
 *
 * This module contains the function `__low_level_init', a function
 * that is called before the `main' function of the program.  Normally
 * low-level initializations - such as setting the prefered interrupt
 * level or setting the watchdog - can be performed here.
 *
 * Note that this function is called before the data segments are
 * initialized, this means that this function can't rely on the
 * values of global or static variables.
 *
 * When this function returns zero, the startup code will inhibit the
 * initialization of the data segments.  The result is faster startup,
 * the drawback is that neither global nor static data will be
 * initialized.
 *
 * Copyright 2003 IAR Systems. All rights reserved.
 *
 * $Revision: 1.6 $
 *
 * $Log $
 *
 **************************************************/
#include "ioADE7169F16.h"

#ifdef __cplusplus
extern "C" {
#endif

#pragma language=extended

//
// Locate low_level_init in the CSTART module
//
#pragma location="CSTART"
//
// If the code model is banked, low_level_init must be declared
// __near_func elsa a ?BRET is performed
//
#if (__CODE_MODEL__ == 2)
__near_func __root char
#else
__root char
#endif
__low_level_init(void)
{
  /*==================================*/
  /*  Initialize hardware.            */
  /*==================================*/
/***********************************************************
  -2/3/2006: Petre M.
  -the core frequency is set to 4.096MHz
  -the XRAM access is enabled
***********************************************************/


  //set 4.096MHz core frequency
  KYREG = 0xa7;
  POWCON=POWCON & 0xF8; //CD2 CD1 CD0=000

  //enable XRAM (Bit0=1)
  CFG = CFG | 0x01;

  /*==================================*/
  /* Choose if segment initialization */
  /* should be done or not.           */
  /* Return: 0 to omit seg_init       */
  /*         1 to run seg_init        */
  /*==================================*/
  return (1);
}

#pragma language=default

#ifdef __cplusplus
}
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?