📄 pwm.s
字号:
.module pwm.c
.area text(rom, con, rel)
.dbfile F:\项目\直流电机\pwm.c
.dbfunc e timers_init _timers_init fV
; a -> R20
.even
_timers_init::
xcall push_gset1
mov R20,R16
sbiw R28,4
.dbline -1
.dbline 5
; #include"iom16v.h"
;
;
; void timers_init(char a)
; {
.dbline 6
; sbit(DDRD,5);
ldi R18,5
ldi R19,0
in R16,0x11
clr R17
xcall _sbit
.dbline 7
; OCR1A=1024-10.24*a;
ldi R16,<L4
ldi R17,>L4
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
ldi R16,<L5
ldi R17,>L5
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
mov R16,R20
clr R17
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall empy32fs
xcall sub32f
movw R30,R28
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L6
ldi R17,>L6
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall cmp32f
brlt L2
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L6
ldi R17,>L6
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall sub32f
xcall fp2int
movw R20,R16
subi R20,0 ; offset = 32768
sbci R21,128
xjmp L3
L2:
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
xcall fp2int
movw R20,R16
L3:
out 0x2b,R21
out 0x2a,R20
.dbline 8
; OCR1B=0x00;
clr R2
clr R3
out 0x29,R3
out 0x28,R2
.dbline 9
; TCNT1=0x00;
out 0x2d,R3
out 0x2c,R2
.dbline 10
; TCCR1A=0xc3;
ldi R24,195
out 0x2f,R24
.dbline 11
; TCCR1B=0x09;
ldi R24,9
out 0x2e,R24
.dbline -2
L1:
adiw R28,4
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r a 20 c
.dbend
.dbfunc e main _main fI
.even
_main::
.dbline -1
.dbline 14
; }
; int main(void)
; {
.dbline 15
; timers_init(25);
ldi R16,25
xcall _timers_init
.dbline -2
L7:
.dbline 0 ; func end
ret
.dbend
.area lit(rom, con, rel)
L6:
.word 0x0,0x4700
L5:
.word 0xd70a,0x4123
L4:
.word 0x0,0x4480
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -