找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

单片机程序请教

[复制链接]
admin 发表于 2012-9-2 22:37:47 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
PULSE_WIDTH_MAX EQU 0F0H
PULSE_WIDTH_MIN EQU 10H
STEP EQU 38H
PULSE_WIDTH EQU 30H
ORG 0000H
AJMP MAIN
ORG 0050H
MAIN: MOV SP,#0E0H
ACALL PCA_INIT
MAIN_LOOP: ACALL PWM
SJMP MAIN_LOOP
PCA_INIT: MOV CMOD,#80H
MOV CCON,#00H
MOV CL,#00H
MOV CH,#00H
MOV CCAPM0,#42H
MOV PCA_PWM0,#00H
MOV PCA_PWM0,#03H
MOV CCAPM1,#42H
MOV PCA_PWM1,#00H
MOV PCA_PWM1,#03H
SETB EPCA_LVD
SETB EA
SETB CR
RET
PWM: MOV A,#PULSE_WIDTH_MIN
MOV PULSE_WIDTH,A
PWM_LOOP1: MOV A,PULSE_WIDTH
CLR C
SUBB A,#PULSE_WIDTH_MAX
JNC PWM_A
MOV A,PULSE_WIDTH
MOV CCAP0,A
MOV CCAP1,A
CPL A
MOV P1,A
MOV A,PULSE_WIDTH
ADD A,#STEP
MOV PULSE_WIDTH,A
ACALL DELAY
SJMP PWM_LOOP1
PWM_A: MOV A,#PULSE_WIDTH_MAX
MOV PULSE_WIDTH,A
PWM_LOOP2: MOV A,PULSE_WIDTH
CLR C
SUBB A,#PULSE_WIDTH_MIN
JC PWM_B
JZ PWM_B
MOV A,PULSE_WIDTH
MOV CCAP0,A
MOV CCAP1,A
CPL A
MOV P1,A
MOV A,PULSE_WIDTH
CLR C
SUBB A,#STEP
MOV PULSE_WIDTH,A
CALL DELAY
SJMP PWM_LOOP2
PWM_B: RET
DELAY: CLR A
MOV R1,A
MOV R2,A
MOV R3,#80H
DELAY_LOOP: NOP
NOP
NOP
DJNZ R1,DELAY_LOOP
DJNZ R2,DELAY_LOOP
DJNZ R3,DELAY-LOOP
RET
END


5_3999_eee543d73fb96a2.jpg
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-29 12:30 , Processed in 0.053150 second(s), 10 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表