231联盟 发表于 2014-2-11 14:39:27

MDK for ARM 中_word()的用法

__word(   ,   )之用法
  在所有的2410或者arm9 的开发板都会用到一个SDRAM.INI,并且里面都用到了__word(, )的这个指令。那这个指令是什么意思呢?今天我们就来解析一下。
  __word(   ,   )是keil软件中自带的一个指令,他的用法是,把某个地址处写如相应的值,相当于把某个地址的寄存器初始化。我们任举一例,_WDWORD(0x53000000, 0x00000000);这个是从所有2410的工程中用到的sdram.ini中copy的一句话,我们查看2410的手册发现,0x53000000这个地址就是看门狗的控制寄存器,写入0x00000000就是关闭看门狗。想必现在大家都懂了吧。下面是sdram.ini这个文件的_word()指令简单注释。希望对大家有帮助。

/******************************************************************************/
/* SDRAM.INI: External RAM (SDRAM) Initialization File                      */
/******************************************************************************/
// <<< Use Configuration Wizard in Context Menu >>>                           //
/******************************************************************************/
/* This file is part of the uVision/ARM development tools.                  */
/* Copyright (c) 2005-2006 Keil Software. All rights reserved.                */
/* This software may only be used under the terms of a valid, current,      */
/* end user licence from KEIL for a compatible version of KEIL software       */
/* development tools. Nothing else gives you the right to use this software.*/
/******************************************************************************/


FUNC void Setup (void) {

_WDWORD(0x53000000, 0x00000000);//关闭看门狗   

_WDWORD(0x4A000008, 0xFFFFFFFF);   // 关闭相应中断
_WDWORD(0x4A00001C, 0x000007FF);       // 关闭相应中断
      
_WDWORD(0x4C000014, 0x00000003);
_WDWORD(0x4C000004, 0x0005c042);          // 时钟分频

_WDWORD(0x56000070, 0x00280000);           //
_WDWORD(0x56000078, 0x00000000);

_WDWORD(0x48000000, 0x22111110);          //SARAM 初始化
_WDWORD(0x48000004, 0x00000700);
_WDWORD(0x48000008, 0x00000700);
_WDWORD(0x4800000C, 0x00000700);
_WDWORD(0x48000010, 0x00000700);
_WDWORD(0x48000014, 0x00000700);
_WDWORD(0x48000018, 0x00000700);
_WDWORD(0x4800001c, 0x00018005);
_WDWORD(0x48000020, 0x00000700);
_WDWORD(0x48000024, 0x008e0459);
_WDWORD(0x48000028, 0x000000B2);
_WDWORD(0x4800002c, 0x00000030);
_WDWORD(0x48000030, 0x00000030);

_WDWORD(0x56000014, 0x00000001);

_WDWORD(0x56000020, 0xAAAA55AA);          //lcd管脚初始化
_WDWORD(0x56000028, 0x0000FFFF);
_WDWORD(0x56000024, 0x00000000);

}

Setup();                                              // Setup for Init

LOAD SDRAM\StepMotor_Test.axf INCREMENTAL            // Download
                                                                                 
PC = 0x30000000;                                                                // <o> Program Entry Point

g, main                                                                                       // Run to main function

sunnyqd 发表于 2014-2-12 23:24:50

是keil软件运行这些代码?以前注意过,但没深究

231联盟 发表于 2014-2-13 09:10:18

sunnyqd 发表于 2014-2-12 23:24
是keil软件运行这些代码?以前注意过,但没深究

是的,mdk中用到的!
页: [1]
查看完整版本: MDK for ARM 中_word()的用法