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-0052
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-0052
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-0052
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-0052
4
Ver. B 2009/08
SM59128 128K Bytes
Application Note
附件二:SM59128 Bank0 及 Bank1 切换及 BankSM59128.A51 说明
1. 如何选择 128K BANK0 或 BANK1:
SCONF ($BFH)
Bit7
Bit6
Bit5
Bit4
WDR
Unused
Unused
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-0052
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
; 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
IF ?B_MODE = 4
;此处 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-0052
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-0052
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-0052
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-0052
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-0052
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-0052
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-0052
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-0052
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-0052
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-0052
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-0052
16
Ver. B 2009/08
SM59128 128K Bytes
Application Note
1.3
按下 NEW FILE 键,输入
整合后之档名。
1.4
按下 COMBINE 键,完成后会显
示”COMBINE OK”,此时已将全部
三个档案整合成一个档案。
附
件
七:
STARTUP.A51 及
Gotoisp.LIB 说明
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0052
17
Ver. B 2009/08
SM59128 128K Bytes
Application Note
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:
MOV
20h,#04h
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0052
18
Ver. B 2009/08
SM59128 128K Bytes
Application Note
b3:
b2:
b1:
MOV
MOV
DJNZ
DJNZ
DJNZ
RET
END
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-0052
19
Ver. B 2009/08