SM59128 128K Bytes Application Notes

SM59128 128K Bytes
Application Note
SM59128 128K Bytes Application Notes
1. 適用產品:SM59128
2. 內容描述:SM59128,128K Bytes ROM 全區域可執行程式之 MCU 應用說明
3. 說明:
3.1. SM59128 128K Bytes 由兩個 64K Bytes Code Memory 組成。(詳細說明如附件一,Page 2~4)
3.2. SM59128 由特殊功能暫存器切換 Bank0 及 Bank1,Common 區需加入 BankSM59128.A51 程式
(定義 SM59128 切換 Bank0 及 Bank1 之機制)。(詳細說明如附件二,Page5~6)
3.3. 建議使用 Keil C 建立 SM59128 之專案。(詳細步驟說明如附件三,Page7~11)
3.4. 可使用燒錄器將程式載入並燒錄方式。(詳細步驟說明如附件四,Page12~13)
3.5. 可使用 ISAP 程式將 Bank0 及 Bank1 程式載入並燒錄方式。
(詳細步驟說明如附件五,Page14~15)
3.6. 可使用 Combiner 程式將 Bank0、Bank1 及 ISP Service Code 整合成一個燒錄檔,方便於開發完
成後生產使用。(詳細步驟說明如附件六,Page16~17)
3.7. STARTUP.A51 及 Gotoisp.LIB 說明。(詳細說明如附件七,Page18~19)
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
1
Ver. B 2009/08
SM59128 128K Bytes
Application Note
附件一:SM59128 128K Bytes Code Memory 架購說明
目前實現 128K 全區域可執行指令的方法,是以搭配 KEIL C 編譯器實現,就 KEIL C 所提供的方案是以虛
擬 Bank 定址區域來擴充可執行區域,但實際上 PC Counter 仍只定址最大 64K 位址,只是當執行 Bank 區
域時可由特定的方式選擇欲執行 Bank0~1。
【例一:Common area 使用 4K Bytes, 則 Bank0 and Bank1 只能使用 60 K Bytes。】
圖一
a.) Bank 數目最大可為 2 個。
b.) Common 區域可為 0000h~FFFFh,依使用者規劃定義。
c.) Bank 區域可定義為 0000h~FFFFh,大小為 64K 減去 Common 定義的大小。
d.) Keil C 所提供之連結器需為 Lx51 (Linker/Locator) ,組譯器需為 CX51 (Compiler)。
e.) 設定 Bank 大小及數量, 選擇 Bank 的方式皆需使用 BankSM59128.A51 進行定義。
1. Common Code Area:
此區域為各 BANK 可共同存取的區域, 下列函式必須存放在此區域:
a.) Reset and Interrupt Vector
b.) Code Constants
c.) Interrupt Functions
d.) Bank Switch Code
e.) Library Function
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
2
Ver. B 2009/08
SM59128 128K Bytes
Application Note
2. Code Bank Areas:
此區域為可超越 64K Code Size 的關鍵,利用 2 個 Bank 區, 組成大於 64K 可執行程式區域,但是各 Bank
無法互相參考與讀取資料,只能透過 Common 區域進行溝通, 實際上對 8051 而言仍是只有 64K ROM 定
址區域,只是當執行 Bank 區時可選擇虛擬擴充的 Bank 區域:
【例二:Common area 使用 16K Bytes, 則 Bank0 and Bank1 只能使用 48 K Bytes。】
圖二
如圖二所示,Bank0 與 Bank1 之間不能相互溝通,若要做溝通需透過 Common 端。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
3
Ver. B 2009/08
SM59128 128K Bytes
Application Note
3. 程式切換示意圖:
圖三
4. 128K Bank 切換示意圖:
圖四
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
4
Ver. B 2009/08
SM59128 128K Bytes
Application Note
附件二:SM59128 Bank0 及 Bank1 切換及 BankSM59128.A51 說明
1. 如何選擇 128K BANK0 或 BANK1:
SCONF ($BFH)
Bit7
Bit6
WDR
Unused
Bit5
Unused
Bit4
Unused
Bit3
BANK
Bit2
ISPE
Bit1
OME
Bit0
ALEI
※WDR: Watch Dog Timer Reset:
當Watch Dog Timer overflow,則WDR=1
※BANK: 64K program Flash bank select bit.
BANK=0,選擇BANK0
BANK=1,選擇BANK1
※ISPE: ISP 啟動位元
ISPE=0,Disable ISP
ISPE=1,Enable ISP
※OME: 768 bytes on-chip RAM 啟動位元,
OME=0,Disable 768 bytes RAM
OME=1,Enable 768 bytes RAM
OME
0
1
address of MOVX below 768
external memory
internal RAM
address of MOVX over 768
external memory
external memory
※ALEI: ALE output inhibit bit,
ALEI=0,ALE Pin沒有任何波型輸出,可以降低EMI
ALEI=1,ALE pin會有 FOSC / 6的頻率輸出
2. BankSM59128.A51 程式內容:
此程式為定義 SM59128 切換 Bank0 及 Bank1 之機制。
;****************************** Configuration Section *******************************
?B_NBANKS
EQU 2
; Define maximum Number of Banks
?B_MODE
EQU 4
; 0 for Bank-Switching via 8051 Port
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
5
Ver. B 2009/08
SM59128 128K Bytes
Application Note
; 1 for Bank-Switching via XDATA Port
; 4 for user-provided bank switch code
;
?B_RTX
EQU 0
;
?B_VAR_BANKING
EQU
?B_RST_BANK
IF ?B_MODE = 4
; 0 for applications without real-time OS
; 1 for applications using the RTX-51 real-time OS
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
EQU 0xFF ; specifies the active code bank number after CPU
;此處 BANK 切換模式為 User 定義, 使用 SFR 方式
;----------------------------------------------------------------------------sconf
DATA
0BfH
;
SWITCH0
MACRO
; Switch to Memory Bank #0
ANL
SCONF,#0F7H
; Clear SCONF Bit 3
ENDM
SWITCH1
MACRO
; Switch to Memory Bank #1
ORL
SCONF,#08H
; SetB SCONF Bit 3
ENDM
ENDIF
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
6
Ver. B 2009/08
SM59128 128K Bytes
Application Note
附件三:在建立 KEIL C Project 時需完成下列步驟:
1. 新增 Common, Bank0, Bank1 共 3 個資料夾。
1.1 於 Options for Target ‘Target 1’中將 Code Banking 勾選,並確認 Banks 為 2。
1.2 選擇 Source Group1 按滑鼠右鍵,選擇 Manage Components。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
7
Ver. B 2009/08
SM59128 128K Bytes
Application Note
1.3 於 Groups 中建立 Common、bank0、bank1 等。
2. 設定下列資料夾屬性(Common,Bank0,Bank1)。
2.1 選擇 Common 按滑鼠右鍵,選擇 Options for Group’Common’。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
8
Ver. B 2009/08
SM59128 128K Bytes
Application Note
2.2 於 Code Bank 中選擇 Common。
2.3 Bank0 及 Bank1 重複 5.2.1 及 5.2.2 選擇 Bank#0 及 Bank#1。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
9
Ver. B 2009/08
SM59128 128K Bytes
Application Note
3. 將 main、STARTUP.A51、BankSM59128.A51 及 Gotoisp.LIB 放入 Common 中。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
10
Ver. B 2009/08
SM59128 128K Bytes
Application Note
3.1 依序將 Bank0 及 Bank1 之程式放入。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
11
Ver. B 2009/08
SM59128 128K Bytes
Application Note
附件四:當編譯完成後,如何將編譯完成的 CODE 燒錄到 SM59128 上:
1. 當編譯完成之後,會產生兩個檔案分別為 test.H00 與 test.H01,其中 128K 為 USER 自己設定的
檔名, H00、H01 為為編譯後所產生的附檔名:
2.
請將 test.H00 與 test.H01 之副檔名改成 HEX:
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
12
Ver. B 2009/08
SM59128 128K Bytes
Application Note
3. 如何於燒錄器上將檔案載入(畫面以 SyncMOS MSM9169 Writer 為例)
3.1 當要載入第一個檔案(test_00.HEX)時的設定:
3.1.1 第一個檔案名稱 : test_00.HEX。
3.1.2 第一個檔案的起始位址:
0x0000H。
3.1.3 第一個檔案其他未使用到的 Buffer
initial Data 設定值:請設定為
0xFF。
3.2 當要載入第二個檔案(test_01.HEX)時的設定:
3.2.1 第二個檔案名稱: test_01.HEX。
3.2.2 第二個檔案其他未使用到的
Buffer initial Data 設定值:請點
選為 Don’t Care。
3.2.3 第二個檔案的起始位址:請設定
為 0x10000H。
3.2.4 當載入第二個檔案時一定要先選
Don’t Care,再設定第二個檔案
的起始位址 0x10000H。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
13
Ver. B 2009/08
SM59128 128K Bytes
Application Note
附件五:使用 ISAP 將 Bank0 及 Bank1 程式載入並燒錄方式
ISAP 程式請於新茂網站下載安裝。
1. 新茂之 SM59128 於出廠時已燒錄 ISP Service Code(於 ISAP 程式安裝完成後,亦提供於安裝目錄下
C:\Program Files\SyncMOS\SyncMOS Writers\ISAP\ISP\ ISP_59128_V01.bin;也可至新茂網站下
載)。
http://www.syncmos.com.tw/download_file/ISP_59128_V01_UART_IIC.rar
2. ISAP 操作步驟如下:
2.1 執行 ISAP 程式,晶片選擇
SM59128,選擇所使用之頻率,選擇
連接之 COM Port,按下掃描鍵。
2.2
此時所選擇連接之 COM Port 旁之燈號由紅
轉綠,ISP 速度會顯示 PC 與 MCU 溝通所使
用之鮑率,於狀態列中會顯示”掃描完成”。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
14
Ver. B 2009/08
SM59128 128K Bytes
Application Note
2.3
按下選擇燒錄檔案中之選擇鍵,將
區塊 0 及區塊 1 勾選,並分別載入
test_00.HEX 及 test_01.HEX
2.4
於燒錄選項中勾選所需執行之功能,再
按下自動執行鍵,所選擇之功能會依序
完成。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
15
Ver. B 2009/08
SM59128 128K Bytes
Application Note
附件六:使用新茂開發之 Combiner 程式將 Bank0、Bank1 及 ISP Service Code 整合
成一個燒錄檔
Combiner 程式請於新茂網站下載安裝。
http://www.syncmos.com.tw/download_file/SyncMOS%20Combiner%20V1.2%20Setup.rar
1. Combiner 操作步驟如下:
1.1
執行 Combiner 程式,晶片選擇
SM59128。
1.2
將 test_00.HEX、test_01.HEX 及
ISP_59128_V01.bin 分別載入。
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
16
Ver. B 2009/08
SM59128 128K Bytes
Application Note
1.3
按下 NEW FILE 鍵,輸入
整合後之檔名。
1.4
按下 COMBINE 鍵,完成後會顯
示”COMBINE OK”,此時已將全部
三個檔案整合成一個檔案。
附
件
七:STARTUP.A51 及
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
17
Ver. B 2009/08
SM59128 128K Bytes
Application Note
Gotoisp.LIB 說明
1.STARTUP.A51(新茂已將之更名為 SyncMOS.a51,請至新茂網站下載):
http://www.syncmos.com.tw/download_file/SyncMOS.a51
1.1 STARTUP.A51 檔案可設定非標準 51 之特殊功能之開啟,例如新茂之擴展 768 Bytes RAM。
1.2 於程式中 STARTUP1 後加入 MOV 0BFH,#02H,將擴展 768 Bytes RAM 致能,於主程式
中就可以正確使用擴展 768 Bytes RAM。
程式部分範例:
STARTUP1:
;*************************************************************
;*****
initial set 0BF=02H
*****
;*************************************************************
MOV
0BFh,#02h
;//add for enable 768 bytes RAM
;****************************************************************
2.Gotoisp.LIB:
2.1 Gotoisp.LIB 為定義使用者進入 ISP Service Code 時,希望表現出之狀態描述。
2.2 最簡單就是產生一個跳躍至 ISP Service Code 位址之動作,如以下敘述。
GotoIsp:
LJMP 0FE00H
END
;isp start address
2.3 或者可以於產生跳躍至 ISP Service Code 位址前,於 Port 0 執行 0X55、0XAA 兩次。
GotoIsp:
MOV
P0,#055h
CALL
delay
MOV
P0,#0AAh
CALL
delay
MOV
P0,#055h
CALL
delay
MOV
P0,#0AAh
CALL
delay
LJMP 0FE00H
;isp start address
delay:
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
18
Ver. B 2009/08
SM59128 128K Bytes
Application Note
b3:
b2:
b1:
MOV
MOV
MOV
DJNZ
DJNZ
DJNZ
RET
END
20h,#04h
21h,#0ffh
22h,#0ffh
22h,b1
21h,b2
20h,b3
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0018
19
Ver. B 2009/08