📄 motor_salve.s
字号:
.module Motor_salve.c
.area text(rom, con, rel)
.dbfile F:\IccAvr_Pro\Motor_salve.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 19
; #include <iom16v.h>
; #include <macros.h>
;
; #include "qep.h"
; #include "SPI_slave.h"
; #include "pwm.h"
;
;
; extern unsigned char SPI_rx_buff[SPI_size];
; extern unsigned char SPI_tx_buff[SPI_size];
; extern unsigned char rx_index;
; extern unsigned char tx_index,SPI_tx_flag;
; extern int qep_cnt[QEP_size];
; extern unsigned char pwm_value[2];
; extern unsigned char pwm_flag;
;
;
; void port_init(void)
; {
.dbline 20
; PORTA = 0xFF;
ldi R24,255
out 0x1b,R24
.dbline 21
; DDRA = 0x00;
clr R2
out 0x1a,R2
.dbline 22
; PORTB = 0xFF;
out 0x18,R24
.dbline 23
; DDRB = 0x00;
out 0x17,R2
.dbline 24
; PORTC = 0x00;
out 0x15,R2
.dbline 25
; DDRC = 0x00;
out 0x14,R2
.dbline 26
; PORTD = 0x00;
out 0x12,R2
.dbline 27
; DDRD = 0x30;
ldi R24,48
out 0x11,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 32
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 34
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 35
; port_init();
xcall _port_init
.dbline 36
; pwm_init();
xcall _pwm_init
.dbline 37
; spi_init();
xcall _spi_init
.dbline 39
;
; MCUCR = 0x0A;
ldi R24,10
out 0x35,R24
.dbline 40
; GICR = 0xC0;
ldi R24,192
out 0x3b,R24
.dbline 41
; TIMSK = 0x00; //timer interrupt sources
clr R2
out 0x39,R2
.dbline 42
; SEI(); //re-enable interrupts
sei
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 46
; //all peripherals are now initialized
; }
; void main(void)
; {
.dbline 47
; init_devices();
xcall _init_devices
xjmp L5
L4:
.dbline 50
;
; while(1)
; {
.dbline 51
; if(pwm_flag)
lds R2,_pwm_flag
tst R2
breq L7
.dbline 52
; {
.dbline 53
; pwm_change();
xcall _pwm_change
.dbline 54
; pwm_flag=0;
clr R2
sts _pwm_flag,R2
.dbline 55
; }
L7:
.dbline 57
L5:
.dbline 49
xjmp L4
X0:
.dbline -2
L3:
.dbline 0 ; func end
ret
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -