歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 使用Keil4開發FL2440開發板 Keil4配置

使用Keil4開發FL2440開發板 Keil4配置

日期:2017/3/1 9:37:38   编辑:Linux編程

一.新建一個keil4工程並進行如下配置

ps.這個Ext_RAM.ini文件需要自己新建一個,文章後附文件內容

單擊setting,配置flash讀寫算法

二.添加代碼

1. 首先添加一個.c文件,寫入程序(帶main),例如跑馬燈程序什麼的。

編譯之後會出現如下問題

first.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST.

這是因為沒有添加.s文件的原因

2. 添加2440init.s文件,網上找一下這個文件,有的。2440init.s包含了三個頭文件option.inc,memcfg.inc, 2440addr.inc也要下載並包含。

編譯後出現如下問題

first.axf: Error: L6218E: Undefined symbol Main (referred from 2440init.o).

這是因為2440程序的默認入口地址不是main,入口地址在2440init.s中有定義。這個入口地址被定義為Main,也就是error中的那個Undefined symbol Main。修改.c文件中main為Main,再編譯就OK了。

三.附
Ext_RAM.ini文件
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 .\first.axf INCREMENTAL // Download program
SetupForStart(); // Setup for Running
g, main // Goto Main

Copyright © Linux教程網 All Rights Reserved