Keil MDK 3.8 + JLink V8 + Mini2440开发板leds点灯程序调试过程

2883阅读 0评论2011-11-23 dfhf2007
分类:

文件:keil_led.rar
大小:50KB
下载:下载

最近刚入手了JLink V8, 开始到网上找资料学习, 发现说的都不是很全面, 现整理一下加上我的一些注释, 希望对新手入门有所帮助. 本文为原创,如有转帖请注明出处!

1.准备工作
2.新建工程
3.设置工程







LR_ROM1 0x30000000 0x01000000 { ; load region size_region
  ER_ROM1 0x30000000 0x01000000 { ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_RAM1 0x31000000 0x04000000 { ; RW data
   .ANY (+RW +ZI)
  }
  RW_IRAM1 0x40000000 0x00001000 {
   .ANY (+RW +ZI)
  }
}





初始化脚本Ext_RAM.ini, 比较关键的一个点是SetupForStart函数里PC的值,如果你的程序载入的内存SDRAM地址是0x30000000(与我们在Target页里的ROM1对应),函数里要把值设为0x30000000.如果要直接下载到SRAM运行,需要修改PC为0x0(Nand 模式)或0x0x40000000(NorLand)模式. 还有对新手比较需要注意的是Load .keil_led.axf命令文件名一定要与Output页里设置的输出路径一致,不然调试无法开始

FUNC void SetupForStart (void) {

// <o> Program Entry Point
  PC = 0x30000000;
}

FUNC void Init (void) {
  _WDWORD(0x4A000008, 0xFFFFFFFF); // Disable All Interrupts

  _WDWORD(0x53000000, 0x00000000); // Disable Watchdog Timer
                                          // Clock Setup
                                        // FCLK = 300 MHz, HCLK = 100 MHz, PCLK = 50 MHz
  _WDWORD(0x4C000000, 0x0FFF0FFF); // LOCKTIME
  _WDWORD(0x4C000014, 0x0000000F); // CLKDIVN
  _WDWORD(0x4C000004, 0x00043011); // MPLLCON
  _WDWORD(0x4C000008, 0x00038021); // UPLLCON
  _WDWORD(0x4C00000C, 0x001FFFF0); // CLKCON

                                        // Memory Controller Setup for SDRAM
  _WDWORD(0x48000000, 0x22000000); // BWSCON
  _WDWORD(0x4800001C, 0x00018005); // BANKCON6
  _WDWORD(0x48000020, 0x00018005); // BANKCON7
  _WDWORD(0x48000024, 0x008404F3); // REFRESH
  _WDWORD(0x48000028, 0x00000032); // BANKSIZE
  _WDWORD(0x4800002C, 0x00000020); // MRSRB6
  _WDWORD(0x48000030, 0x00000020); // MRSRB7

  _WDWORD(0x56000000, 0x000003FF); // GPACON: Enable Address lines for SDRAM
}


// Reset chip with watchdog, because nRST line is routed on hardware in a way
// that it can not be pulled low with ULINK

_WDWORD(0x40000000, 0xEAFFFFFE); // Load RAM addr 0 with branch to itself
CPSR = 0x000000D3; // Disable interrupts
PC = 0x40000000; // Position PC to start of RAM
_WDWORD(0x53000000, 0x00000021); // Enable Watchdog
g, 0 // Wait for Watchdog to reset chip

Init(); // Initialize memory
LOAD .\keil_led.axf INCREMENTAL // Download program
SetupForStart(); // Setup for Running
g, main



4.开始调试
 通过Project-Build Target菜单编译整个项目,通过Debug菜单开始调试程序, 开始你的ARM调试之旅吧.
上一篇:LCD & framebuffer开发心得
下一篇:mini2440裸机程序-uart