.include "m16def.inc"
.cseg
.org 0
jmp start
.org ovf0addr
jmp t0int
.org icp1addr
jmp t0cp
.org $30
dada:
.db 21,24,27,30,34,37,40,43,46,49,52,55,58,61,63,66,69,72,74,77,80,82,84,87,89,91,93,96,98,99,101,103,105,106,108,109,111,112,113,114,115,116,117,117,118,119,119,119,119,119,119,119,119,119,119,118,117,117,116,115,114,113,112,111,109,108,106,105,103,101,99,98,96,93,91,89,87,84,82,80,77,74,72,69,66,63,61,58,55,52,49,46,43,40,37,34,30,27,24,21
start:
ldi r20, $4
ldi r21, $5f
out sph, r20
out spl, r21
;call init0
call init1
call iniport
bset i
here:
rjmp here
init0:
in r20, tccr0
ldi r21, $1
or r20, r21
ldi r21, $f9
and r20, r21
out tccr0, r20
in r20, timsk
ldi r21, $1
or r20, r21
out timsk, r20
ret
init1:
ldi r20, $a2
out tccr1a, r20
ldi r20, $11
out tccr1b, r20
ldi r20, 00
ldi r21, 50
out ocr1ah, r20
out ocr1al, r21
out ocr1bh, r20
out ocr1bl, r21
ldi r21, 150
out icr1h, r20
out icr1l, r21
in r20, timsk
ldi r21, $20
or r20, r21
out timsk, r20
ret
iniport:
ldi r20, $ff;
out ddrb, r20;
ldi r20, 255
out ddrd, r20
out portd, r20
ret
t0int:
in r20, portb
inc r20
out portb, r20
reti
t0cp:
;count = r30
;temp = r19
;zf = T in sreg
cpi r30, $c4
brne onwheel
overwheel:
ldi r31, $00
ldi r30, $60
in r20, sreg
ldi r21, $40
eor r20, r21
out sreg, r20
onwheel:
lpm r19, z+
brts zheng
brtc fan
zheng:
ldi r20, 1
out ocr1bh, r20
out ocr1bl, r20
ldi r20, 00
out ocr1ah, r20
out ocr1al, r19
reti
fan:
ldi r20, 1
out ocr1ah, r20
out ocr1al, r20
ldi r20, 00
out ocr1bh, r20
out ocr1bl, r19
reti
上传一份完整的SPWM code in ASM,也旨在提高国人的设计水平
全部回复(15)
正序查看
倒序查看
现在还没有回复呢,说说你的想法
@courier
zack如果你看到的话,向你表示致意.用AVRstdio4编译.这是个表长为100的spwm发生器的源程序,我编的,用t1的两路比较器分别输出正反半周期的脉冲,好处是可以直接用于互补型的功率输出,表中死区已经留出来了.如果需要不同波形,可以通过该表方便的进行调整.如果希望交流,可以和我联系:wql81@sohu.com
courier,not bad!
I think it would be much better if you do some remarks after every instruction.
qq 27579653
I think it would be much better if you do some remarks after every instruction.
qq 27579653
0
回复
提示