我想做个CNC切割机玩的,论坛里找到相关电路和汇编的程序,本人不懂单片机编程,试着用keil c51软件把汇编程序转成HEX文件,可没有成功。
KEIL软件提示:
Build target 'Target 1'
assembling STARTUP.A51...
assembling 2051.asm...
linking...
BL51 BANKED LINKER/LOCATER V6.00 - SN: K1NGC-7HHKCR
COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2005
"C:\Documents and Settings\Administrator\桌面\STARTUP.obj",
"C:\Documents and Settings\Administrator\桌面\2051.obj"
TO "C:\Documents and Settings\Administrator\桌面\cnc.hex" Rtx51
PRINT(".\cnc.m51")
*** FATAL ERROR L210: I/O ERROR ON INPUT FILE:
EXCEPTION 0021H: PATH OR FILE NOT FOUND
FILE: C:\Documents and Settings\Administrator\桌面\2051.obj
Target not created
哪位高手帮帮忙啊,下面的汇编程序该怎么编译成hex文件啊,懂的来教教我吧,非常感谢。
源程序:
;copyright by yyj (sgyyj@yahoo.com.cn)
;2004-2-5 应茂名李剑峰要求,做CNC切割接口,因为买不到UNC5084 步进马达驱动
;2004-4-4 测试自制CNC切割软件 ,CPU 2051 CK = 6 Mhz
; P1口直接驱动L3803 N-mosfet, P1.0-P1.3 为马达1 , P1.4-P1.7为马达2
;2004-4-9 加入50%/25%的PWM在没输入时,自动降电流,取消CLK输出功能改为TEST脉冲输出
DOG EQU 7FH ;看门狗计数
TEST EQU P3.7 ;测试脉冲输出
STEP1 EQU P3.2 ;马达1步脉冲
DIREC1 EQU P3.4 ;马达1方向
STEP2 EQU P3.3 ;马达2步脉冲
DIREC2 EQU P3.5 ;马达2方向
HALF_KEY EQU P3.1 ;全步/半步选择
PWM_K EQU P3.0 ;50%PWM /25%PWM 选择
LOOP1 EQU 70H
LOOP2 EQU 71H
CLK EQU 72H
PWM_DL EQU 73H ;PWM运行延迟
PWM_FLAG EQU 20H ;允许PWM运行
OUT EQU 21H ; PWM时 输出状态 1=FET ON ,0=FET OFF
RUN EQU 22H
#CLK_LOOP EQU #2
#PWM_TM EQU #4 ;PWM运行延迟时间 * 0.131s
ORG 000H
REST: LJMP RST
;--INT0--中断
ORG 003H
LJMP INT0
DB 80H,0E7H
;---T0---CLK PWM发生器/测试脉冲发生器 中断处理-------
ORG 00BH
T001: LJMP T0
DB 30H,0A5H
;--INT1--中断
ORG 013H
LJMP INT1
DB 07H,67H
;---T1---中断
ORG 01BH
LJMP T1
DB 32H,1FH,0BH,8AH,37H,0E0H,7CH,65H,0D9H,1EH,9AH,6CH,9AH,,0F5H,32H
ORG 030H
T0: DJNZ R7,T003
MOV R7,#5
CPL TEST
T003: JNB PWM_FLAG,T0100 ;PWM_FLAG=0则不处理,直接输出TEST周期方波
DJNZ CLK,T0100
MOV CLK,#CLK_LOOP
JB OUT,T021 ;ON-->0FF = 256*2us=512us
SETB OUT
JB PWM_K,T011 ;OFF-->ON = 512*2us / 128*2us
MOV TH0,#80H
RETI
T011: MOV TH0,#0H
RETI
T021: CLR OUT
T0100: RETI
DB 08H,0CH,04H,06H,02H,03H,01H,09H,32H
DB 09H,0CH,06H,03H,32H
;-----0.131 s 看门狗中断处理- 33s 后复位----
ORG 060H
T1: DJNZ DOG,T101
CLR IE.7
RRST: MOV DPTR,#RST
PUSH DPL
PUSH DPH
T101: DJNZ PWM_DL,T102
MOV PWM_DL,#PWM_TM
SETB PWM_FLAG
T102: RETI
;============= RESET ===========
RST: CLR IE.7 ;禁止中断
MOV P1,#00000000B; P1 =0,关闭 MOSFET
MOV TCON,#05H ;停止 T0,T1 , INT0,INT1 跳变触发
MOV P3,#11111111B
MOV TMOD,#12H ; T1: 16位定时器,T0: 8位自装入定时器
MOV IP,#0AH ; T0,T1 中断优先
MOV TH0,#0
MOV TL0,#0
MOV PSW,#0
MOV SP,#28H ;SP = 28 H 开始
MOV DPTR,#MAIN
PUSH DPL
PUSH DPH
RETI
;--------------主程式-------------
MAIN: CLR FO
MOV TCON,#55H ;启动 T0、T1
MOV IE,#8FH ;INT0,INT1,T0、T1可以中断 ,DOG在没有输入步进信号33 秒后启动复位
MOV R3,#88H ;初始输出值
CLR RUN
MOV PWM_DL,#PWM_TM
MOV CLK,#CLK_LOOP
MAIN1: JNB RUN,MAIN1
MOV DOG,#0
MOV TL1,#0
MOV TH1,#0
CLR PWM_FLAG ;关闭PWM
MAIN2: JNB PWM_FLAG,MAIN2 ;PWM_FLAG=0 则不处理
JNB OUT,MA10
MOV P1,R3
SJMP MAIN2
NOP
NOP
NOP
MA10: MOV P1,#0
SJMP MAIN2
ORG 300H
;-----------INT0 马达1步脉冲下沿触发-----
INT0: JNB FO,INT000
LCALL START
INT000: JNB DIREC1,INT001
INC LOOP1
SJMP INT002
INT001: DEC LOOP1
INT002: JNB HALF_KEY,INT010 ;低电平为 HALF方式
MOV DPTR,#DATA1
ANL LOOP1,#3 ;4 STEP
SJMP INT011
INT010: MOV DPTR,#DATA11
ANL LOOP1,#7 ;8 STEP
INT011: MOV A,LOOP1
MOVC A,@A+DPTR
MOV R1,A
MOV A,R3
ANL A,#0F0H
ORL A,R1
SJMP OUT_END
DB 97H
;-----------INT1 马达2步脉冲下沿触发-----
ORG 330H
INT1: JNB FO,INT100
LCALL START
INT100: JNB DIREC2,INT101
INC LOOP2
SJMP INT102
INT101: DEC LOOP2
INT102: JNB HALF_KEY,INT110 ;低电平为 HALF方式
MOV DPTR,#DATA2
ANL LOOP2,#3 ;4 STEP
SJMP INT111
INT110: MOV DPTR,#DATA21
ANL LOOP2,#7 ;8 STEP
INT111: MOV A,LOOP2
MOVC A,@A+DPTR
MOV R2,A
MOV A,R3
ANL A,#0FH
ORL A,R2
OUT_END:MOV P1,A
SETB RUN
MOV R3,A ;R3保留输出值
POP A
POP B
MOV DPTR,#MAIN1
PUSH DPL
PUSH DPH
RETI
START: CLR FO
MOV A,#88H
SJMP OUT_END
RETI
DATA1: DB 09H,0CH,06H,03H ; TWO PHASE 4 STEP
DATA11: DB 08H,0CH,04H,06H,02H,03H,01H,09H ;HALF PHASE 8 STEP
DATA2: DB 090H,0C0H,060H,030H ; TWO PHASE 4 STEP
DATA21: DB 080H,0C0H,040H,060H,020H,030H,010H,090H ;HALF PHASE 8 STEP
NOP
RETI
ORG 07FDH
LJMP REST
[ 本帖最后由 小小飞侠 于 2009-4-2 17:30 编辑 ] |