|
轉(zhuǎn)了一篇文章你學(xué)習(xí)一下:
使用單片機(jī)編程的朋友們都知道,常規(guī)的51系列單片機(jī)地址尋址空間只有64K,如果程序編寫超過64K,那么只好通過增加外部程序存儲(chǔ)器來實(shí)現(xiàn)目標(biāo),但是如果這樣做無疑增加了硬件成本,單片機(jī)生產(chǎn)商為了解決這個(gè)問題,現(xiàn)在已經(jīng)開發(fā)出可尋址128K、256K,甚至更大ROM的單片機(jī)。
但是熟知keil的人都知道,keil默認(rèn)64K尋址,如果想要做超過64K的程序該如何設(shè)置呢?這就要利用keil開發(fā)出來的BL51功能,下面以芯唐單片機(jī)W77E532為例進(jìn)行介紹,具體操作步驟如下:
首先打開keil并選擇要使用的芯片,如W77E532,之后點(diǎn)擊“USE EXTENDED LINKER(LX51) INSTEAD OF BL51”為選中狀態(tài);之后設(shè)置點(diǎn)擊“TARGET”設(shè)置晶振頻率和memory model為small、code rom size為large、operating為none,該窗口下面的“code banking”選中,同時(shí)設(shè)置bank分區(qū),如W77E532為2,后面的START和END可以設(shè)置成0x0000和0xFFFF;接下來設(shè)置“OUTPUT”點(diǎn)擊“Create HEX Fi:”從后面的下拉列表中選擇“HEX-386”,這些全部設(shè)置完成后點(diǎn)擊“確定”以完成設(shè)置。
接下來開始設(shè)置工程信息,點(diǎn)擊菜單欄中的“project”并選擇下面的“Components,Environment,Books...”項(xiàng),在group中添加3個(gè)分區(qū)的文件目錄,依次為root,bank和bank1,
之后在各個(gè)目錄下面添加屬于該目錄的文件,
設(shè)置完成后點(diǎn)擊“確定”保存。
當(dāng)這些都設(shè)置完成后,在左側(cè)“project workspace”區(qū)域?qū)oot,bank和bank1的code bank和stop on exit分別設(shè)置,依次為:
common和translator fatal errors (exit code >=3),
bank#0和translator fatal errors (exit code >=3),
bank#1和translator fatal errors (exit code >=3);
之后對(duì)各個(gè)目錄右側(cè)進(jìn)行設(shè)置,只選擇“include in target build”,其余為空狀態(tài),點(diǎn)擊“確定”完成設(shè)置。
注意在root目錄中必須有L51_BANK.A51和STARTUP.A51存在,而L51_BANK.A51文件根據(jù)用戶使用進(jìn)行實(shí)際配置,配置區(qū)域如下:
$NOMOD51 NOLINES
$NOCOND
;------------------------------------------------------------------------------
; This file is part of the BL51 / LX51 Banked Linker/Locater package
; Copyright (c) 1988 - 2005 Keil Elektronik GmbH and Keil Software, Inc.
; Version 2.21 (Code and Variable Banking for Classic 8051 Derivatives)
;------------------------------------------------------------------------------
;************************ Configuration Section *******************************
?B_NBANKS EQU 2 ; Define maximum Number of Banks *
; ; following values are allowed: 2, 4, 8, 16, 32, 64 *
; ; for BL51 the maximum value for ?B_BANKS is 32 *
; ; for LX51 the maximum value for ?B_BANKS is 64 *
; *
?B_MODE EQU 0 ; 0 for Bank-Switching via 8051 Port *
; ; 1 for Bank-Switching via XDATA Port *
; ; 4 for user-provided bank switch code *
; *
?B_RTX EQU 0 ; 0 for applications without real-time OS *
; ; 1 for applications using the RTX-51 real-time OS *
; *
?B_VAR_BANKING EQU 1 ; Variable Banking via L51_BANK (far memory support)*
; ; 0 Variable Banking does not use L51_BANK.A51 *
; ; 1 Variable Banking uses this L51_BANK.A51 module *
; Notes: ?B_VAR_BANKING uses the 'far' and 'far const' C51 memory types to *
; extent the space for variables in RAM and/or ROM of classic 8051 *
; device. The same hardware as for code banking is used. Program *
; code banking and variable banking share the same hardware I/O pins. *
; The C51 Compiler must be used with the VARBANKING directive. *
; Variable Banking is only supported with the LX51 linker/locater. *
; *
?B_RST_BANK EQU 0 ; specifies the active code bank number after CPU *
; ; Reset. Used to reduce the entries in the *
; ; INTERBANK CALL TABLE. The value 0xFF disables *
; ; this LX51 linker/locater optimization. *
; Note: Interbank Call Table optimization is only possible with LX51. *
; *
;-----------------------------------------------------------------------------*
; *
IF ?B_MODE = 0; *
;-----------------------------------------------------------------------------*
; if ?BANK?MODE is 0 define the following values *
; For Bank-Switching via 8051 Port define Port Address / Bits *
; *
P1 DATA 90H ; I/O Port Address *
; *
?B_PORT EQU P1 ; default is P1 *
?B_FIRSTBIT EQU 7 ; default is Bit 2 *
;-----------------------------------------------------------------------------*
ENDIF;
以上部分需要用戶根據(jù)分區(qū)數(shù)量和用途自行設(shè)置。
注意:root和bank可以看做在一個(gè)分區(qū),初始化的時(shí)候?qū)⑦@兩個(gè)目錄分在一起,bank1要靠root選擇,一般使用P1口的后面幾個(gè)引腳做分區(qū)使用,不能外接設(shè)備。 |
|