|
PIC程序转换至EM78XX
1、芯片对照 | 答:PIC其中一些单片机与EM78系列单片机管脚相兼容,对照如下:
- PIC12C508/509 EM78P152/153
- PIC16C54/56/84 EM78P156/256/456
- PIC16C55/57 EM78P447
以上单片机转换可以在不用改动PCB情况便可完成,具体硬件资源对照如表1所示。
| 2、指令对照表 | 答:指令对照表如表2所示 | 3、转换软件使用说明 | 答:现有转换软件X156M.EXE可以将PIC编写的程序目标码转成EM78单片机可用的源代码。
文件名:X156M.EXE
说明:PIC程序文件名后缀一定是(.OBJ)
文件格式是16进制(HEX)或二进制(BIN)
执行X156M(以5XDEMO.OBJ为例、HEX格式)
提示输入文件5XDEMO.OBJ
询问是何种文件输出方式(H/B)?选H
询问文件大小(单位是512字节)?输入1(16C54、12C508)或2(16C56)或4(16C57)
询问文件输出方式(0/1)?选1
询问WDT开/关否?(视情况而定)
至此,可输出名为5XDEMO.DT文件(即EM78XX的源程序) 注:经过上述转换的程序仍可能存在下列问题,需要修正:
- 针对EMC内部RAM地址比PIC高10H,转换程序对RAM地址硬性加10H,如此时R4则转为R14,如果R4作间接寻址用,此时应恢复R14棗R4;在间接寻址中,在赋给R4立即数的值转到EMC时该立即数也应加10H; 相关的BANK选择位对应如(前为PIC,后为EMC)∶R3.5à R3.6,R3.6à R3.7.
- PIC和EMC个别寄存器如标志寄存器R3.7、R4不一样,有些PIC程序中用了其中闲置的bit做标志位,到EMC程序中要检查有没有冲突;
- PIC和EMC读入RA或口5,闲置位赋值不一样:如PIC16C54读RA.时RA的高四位为0,但EM78×56就不是为0,所以EM78X56读出口5数据时要屏蔽高位,否则容易出错。
针对PIC16C57程序转换的问题(1)R7转换后会变成17H,应恢复为07H;(2)为了避免程序跳转、R3的重定义而出现的错误,最好将16C57对应的4个PAGES映射到78P447的4个PAGES里去,方法是重定义转换程序的每页起始地址,200Hà 400H,400Hà 800H,600Hà C00H。
| 表1 PIC和EMC单片机硬件资源对照表
Devicc
| EM78P152
EM78P153 | PIC12C508
PIC12C509
| EM78P156 | PIC16C54
PIC16C56
| EM78P447A
EM78P447B
| PIC16C57
| Pins
| 8/14
| 8
| 18
| 18
| 28/32
| 28
| Process
| CMOS
| CMOS
| CMOS
| CMOS
| CMOS
| CMOS
| Architecture
| RISC
| RISC
| RISC
| RISC
| RISC
| RISC
| Mask Version
| Yes
| N/A
| Yes
| N/A
| Yes
| N/A
| Working Voltage
| 2.5~5.5
| 2.5~5.5
| 2.5~5.5
| 2.5~6.25
| 2.3~5.5
| 2.5~6.25
| Program Memory
| 512x13
| 512/1Kx12
| 1Kx13
| 512/1Kx12
| 4Kx13
| 2Kx12
| User Memory RAM
| 32x8
| 25/41x8
| 48x8
| 25x8
| 148x8
| 72x8
| I/O pins
| 6/12
| 5
| 12
| 12
| 20/24
| 20
| Instruction Clock
| 2
| 4
| 2
| 4
| 2
| 4
| Oscillation Mode
| 5
| 4
| 4,(5)
| 4
| 4
| 4
| Instruction Set
| 57
| 33
| 57
| 33
| 57
| 33
| Max.Operating
| XT
| 16(4 clks)
| 8(4 clks)
| 18(2 clks)36(4clks)
| 20(4 clks)
| 36(4 clks)
| 20(4 clks)
| RC
| 4(4 clks)
| 4(4 clks)
| 4(4 clks)
| 4(4 clks)
| 4(4 clks)
| 8(4 clks)
| Page Size
| 1K
| 512
| 1K
| 512
| 1K
| 512
| Available for CALL
| 1K
| 256
| 1K
| 256
| 1K
| 256
| Option Code
| 13
| N/A
| 6
| N/A
| 7(13)
| N/A
| Iterrupt(In/Ex)
| 3(1/2)
| N/A
| 3(1/2)
| N/A
| 3(1/2)
| N/A
| Pull-High Pins
| 6/8
| N/A
| 8
| N/A
| 10
| N/A
| Pull-Low Pins
| 3/7
| N/A
| 7
| N/A
| 0
| N/A
| Wake-Up Pins
| 6/8
| N/A
| 8
| N/A
| 10
| N/A
| Open-Drain Pins
| 6/8
| N/A
| 8
| N/A
| 2
| N/A
| R-Option Pins
| 0
| N/A
| 2
| N/A
| 2
| N/A
| Stack
| 5
| 2
| 5
| 2
| 5
| 2
| POVD
| Yes
| N/A
| Yes
| N/A
| Yes
| N/A
| Timer Modules
| 8-bitx1
| 8-bitx1
| 8-bitx1
| 8-bitx1
| 8-bitx1
| 8-bitx1
| WDT
| Yes
| Yes
| Yes
| Yes
| Yes
| Yes
|
表2 PIC和EMC指令对照表
PIC
| EMC
| 字 节 操 作 指 令
| NOP
| | NOP
| | NOVWF
| f | MOV
| R,A | CLRW
| | CLRA
| | CLRF
| f | CLR
| R | SUBWF
| f,0 | SUB
| A,R | SUBWF
| f,1 | SUB
| R,A | DECF
| f,0 | DECA
| R | DECF
| f,1 | DEC
| R | IORWF
| f,0 | OR
| A,R | IORWF
| f,1 | OR
| R,A | ANDWF
| f,0 | AND
| A,R | ANDWF
| f,1 | AND
| R,A | XORWF
| f,0 | XOR
| A,R | XORWF
| f,1 | XOR
| R,A | ADDWF
| f,0 | ADD
| A,R | ADDWF
| f,1 | ADD
| R,A | MOVF
| f,0 | MOV
| A,R | MOVF
| f,1 | MOV
| R,R | COMF
| f,0 | COMA
| R | COMF
| f,1 | COM
| R | INCF
| f,0 | INCA
| R | INCF
| f,1 | INC
| R | DECFSZ
| f,0 | DJZA
| R | DECFSZ
| f,1 | DJZ
| R | RRF
| f,0 | RRCA
| R | RRF
| f,1 | RRC
| R | RLF
| f,0 | RLCA
| R | RLF
| f,1 | RLC
| R | SWAPF
| f,0 | SWAPA
| R | SWAPF
| f,1 | SWAP
| R | INCFSZ
| f,0 | JZA
| R | INCFSZ
| f,1 | JA
| R | 位 操 作 指 令
| BCF
| f,b | BC
| R,b | BSF
| f,b | BS
| R,b | BTFSC
| f,b | JBC
| R,b | BTFSS
| f,b | JBS
| R,B | 控 制 指 令
| OPTION
| | CONTW
| | SLEED
| | SLEP
| | CLRWDF
| | WDTC
| | TRIS
| f | IOW
| R | RETLW
| k | RETL
| K | CALL
| k | CALL
| K | GOTO
| k | JMP
| K | MOVLW
| k | MOV
| A,K | IORLW
| k | OR
| A,K | ANDLW
| k | AND
| A,K | XORLW
| k | XOR
| A,K | 其它
| | DAA
| | | ENI
| | | DISI
| | | RET
| | | RETI
| | | CONTR
| | | IOR
| R | | SUB
| A,K | | INT
| | | ADD
| A,K |
|
|
|