?? 角度傳感器.s
字號:
.module _角度傳感器.c
.area text(rom, con, rel)
.dbfile ..\22角度~1\角度傳感器.c
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.dbfunc e delay _delay fV
.even
_delay::
.dbline -1
.dbline 15
; #include <iom16v.h>
; #include <macros.h>
; #define uchar unsigned char
; #define uint unsigned int
;
; #define clk 7
; #define set_clk PORTC |= BIT(clk)
; #define clr_clk PORTC &= ~BIT(clk)
;
; #define sid 6
; #define clr_sid PORTC &= ~BIT(sid)
; #define set_sid PORTC |= BIT(sid)
;
; void delay()
; {
.dbline 16
; NOP();
nop
.dbline 17
; NOP();
nop
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e delay_us _delay_us fV
; i -> R16,R17
.even
_delay_us::
.dbline -1
.dbline 20
; }
; void delay_us(uint i)
; {
L3:
.dbline 22
; while(i--)
; {;}
.dbline 22
.dbline 22
L4:
.dbline 21
movw R2,R16
subi R16,1
sbci R17,0
tst R2
brne L3
tst R3
brne L3
X0:
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbsym r i 16 i
.dbend
.dbfunc e delay_ms _delay_ms fV
; a -> R20,R21
; i -> R16,R17
.even
_delay_ms::
st -y,R20
st -y,R21
.dbline -1
.dbline 25
; }
; void delay_ms(uint i)
; {
.dbline 27
; uint a;
; for(;i;i--)
xjmp L10
L7:
.dbline 28
; {
.dbline 29
; for(a=0;a<672;a++);
clr R20
clr R21
xjmp L14
L11:
.dbline 29
L12:
.dbline 29
subi R20,255 ; offset = 1
sbci R21,255
L14:
.dbline 29
cpi R20,160
ldi R30,2
cpc R21,R30
brlo L11
X1:
.dbline 30
; }
L8:
.dbline 27
subi R16,1
sbci R17,0
L10:
.dbline 27
cpi R16,0
cpc R16,R17
brne L7
X2:
.dbline -2
L6:
.dbline 0 ; func end
ld R21,y+
ld R20,y+
ret
.dbsym r a 20 i
.dbsym r i 16 i
.dbend
.dbfunc e wr_bit _wr_bit fV
; data -> R10
; n -> R12
.even
_wr_bit::
st -y,R10
st -y,R12
mov R10,R18
mov R12,R16
.dbline -1
.dbline 33
; }
; void wr_bit(uchar n,uchar data)
; {
.dbline 34
; for(;n;n--) //寫入位數(shù)
xjmp L19
L16:
.dbline 35
; {
.dbline 36
; if(data&0x80)
sbrs R10,7
rjmp L20
X3:
.dbline 37
; {set_sid;}
.dbline 37
sbi 0x15,6
.dbline 37
xjmp L21
L20:
.dbline 39
; else
; {clr_sid;}
.dbline 39
cbi 0x15,6
.dbline 39
L21:
.dbline 40
; data=data<<1;
lsl R10
.dbline 41
; delay();
xcall _delay
.dbline 42
; set_clk;
sbi 0x15,7
.dbline 43
; delay();
xcall _delay
.dbline 44
; clr_clk;
cbi 0x15,7
.dbline 45
; }
L17:
.dbline 34
dec R12
L19:
.dbline 34
tst R12
brne L16
X4:
.dbline -2
L15:
.dbline 0 ; func end
ld R12,y+
ld R10,y+
ret
.dbsym r data 10 c
.dbsym r n 12 c
.dbend
.dbfunc e write_shuju _write_shuju fV
; b -> R20
; a -> R10
.even
_write_shuju::
st -y,R10
st -y,R20
mov R20,R18
mov R10,R16
.dbline -1
.dbline 48
; }
; void write_shuju(uchar a,uchar b)
; {
.dbline 49
; clr_clk;
cbi 0x15,7
.dbline 51
;
; wr_bit(5,0xFF);
ldi R18,255
ldi R16,5
xcall _wr_bit
.dbline 53
;
; wr_bit(1,0x00);
clr R18
ldi R16,1
xcall _wr_bit
.dbline 55
;
; if(a==0)
tst R10
brne L23
X5:
.dbline 56
; wr_bit(1,0x00);
clr R18
ldi R16,1
xcall _wr_bit
xjmp L24
L23:
.dbline 58
; else
; wr_bit(1,0x80);
ldi R18,128
ldi R16,1
xcall _wr_bit
L24:
.dbline 60
;
; wr_bit(1,0x00); //寫入一個0
clr R18
ldi R16,1
xcall _wr_bit
.dbline 62
;
; wr_bit(4,b); //寫入數(shù)據(jù)的高4位
mov R18,R20
ldi R16,4
xcall _wr_bit
.dbline 64
;
; wr_bit(4,0x00); //寫入4個0
clr R18
ldi R16,4
xcall _wr_bit
.dbline 66
;
; wr_bit(4,(b<<4)); //寫入數(shù)據(jù)的低4位
mov R18,R20
andi R18,#0x0F
swap R18
ldi R16,4
xcall _wr_bit
.dbline 68
;
; wr_bit(4,0x00); //寫入4個0
clr R18
ldi R16,4
xcall _wr_bit
.dbline 70
;
; set_sid;
sbi 0x15,6
.dbline -2
L22:
.dbline 0 ; func end
ld R20,y+
ld R10,y+
ret
.dbsym r b 20 c
.dbsym r a 10 c
.dbend
.dbfunc e lcd12864_init _lcd12864_init fV
.even
_lcd12864_init::
.dbline -1
.dbline 73
; }
; void lcd12864_init()
; {
.dbline 74
; write_shuju(0,0x30); //設置數(shù)據(jù)方式:8位
ldi R18,48
clr R16
xcall _write_shuju
.dbline 75
; delay_us(200);
ldi R16,200
ldi R17,0
xcall _delay_us
.dbline 76
; write_shuju(0,0x30); //設置數(shù)據(jù)方式:8位
ldi R18,48
clr R16
xcall _write_shuju
.dbline 77
; delay_us(80);
ldi R16,80
ldi R17,0
xcall _delay_us
.dbline 78
; write_shuju(0,0x0C); //開顯示
ldi R18,12
clr R16
xcall _write_shuju
.dbline 79
; delay_us(80);
ldi R16,80
ldi R17,0
xcall _delay_us
.dbline 80
; write_shuju(0,0x40); //開顯示
ldi R18,64
clr R16
xcall _write_shuju
.dbline 81
; delay_us(200);
ldi R16,200
ldi R17,0
xcall _delay_us
.dbline 82
; write_shuju(0,0x01); //清屏
ldi R18,1
clr R16
xcall _write_shuju
.dbline 83
; delay_ms(100);
ldi R16,100
ldi R17,0
.dbline -2
L25:
.dbline 0 ; func end
xjmp _delay_ms
.dbend
.dbfunc e write_hz _write_hz fV
; s -> R20,R21
.even
_write_hz::
st -y,R20
st -y,R21
movw R20,R16
.dbline -1
.dbline 87
;
; }
; void write_hz(char *s)
; {
xjmp L28
L27:
.dbline 89
; while(*s)
; {
.dbline 90
; write_shuju(1,*s);
movw R30,R20
ldd R18,z+0
ldi R16,1
xcall _write_shuju
.dbline 91
; s++;
subi R20,255 ; offset = 1
sbci R21,255
.dbline 92
; }
L28:
.dbline 88
movw R30,R20
ldd R2,z+0
tst R2
brne L27
X6:
.dbline -2
L26:
.dbline 0 ; func end
ld R21,y+
ld R20,y+
ret
.dbsym r s 20 pc
.dbend
.dbfunc e locate _locate fV
; y -> R20
; x -> R10
.even
_locate::
xcall push_xgsetF00C
mov R20,R18
mov R10,R16
.dbline -1
.dbline 95
; }
; void locate(uchar x,uchar y)
; {
.dbline 96
; switch(x)
mov R22,R10
clr R23
cpi R22,1
ldi R30,0
cpc R23,R30
breq L34
X7:
cpi R22,2
ldi R30,0
cpc R23,R30
breq L35
X8:
cpi R22,3
ldi R30,0
cpc R23,R30
breq L36
X9:
cpi R22,4
ldi R30,0
cpc R23,R30
breq L37
X10:
xjmp L32
L34:
.dbline 98
; {
; case 1:write_shuju(0,(0x80+y-1)); break;
mov R18,R20
subi R18,128 ; addi 128
subi R18,1
clr R16
xcall _write_shuju
.dbline 98
xjmp L32
L35:
.dbline 99
; case 2:write_shuju(0,(0x90+y-1));break;
mov R18,R20
subi R18,112 ; addi 144
subi R18,1
clr R16
xcall _write_shuju
.dbline 99
xjmp L32
L36:
.dbline 100
; case 3:write_shuju(0,(0x88+y-1));break;
mov R18,R20
subi R18,120 ; addi 136
subi R18,1
clr R16
xcall _write_shuju
.dbline 100
xjmp L32
L37:
.dbline 101
; case 4:write_shuju(0,(0x98+y-1));break;
mov R18,R20
subi R18,104 ; addi 152
subi R18,1
clr R16
xcall _write_shuju
.dbline 101
.dbline 102
; default:break;
L32:
.dbline -2
L30:
.dbline 0 ; func end
xjmp pop_xgsetF00C
.dbsym r y 20 c
.dbsym r x 10 c
.dbend
.dbfunc e cls _cls fV
.even
_cls::
.dbline -1
.dbline 106
; }
; }
; void cls()
; {
.dbline 107
; delay_us(200);
ldi R16,200
ldi R17,0
xcall _delay_us
.dbline 108
; write_shuju(0,0x01); //清屏
ldi R18,1
clr R16
xcall _write_shuju
.dbline 109
; delay_ms(20);
ldi R16,20
ldi R17,0
.dbline -2
L38:
.dbline 0 ; func end
xjmp _delay_ms
.dbend
.area vector(rom, abs)
.org 44
jmp _uart0_rx_isr
.area text(rom, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.area vector(rom, abs)
.org 52
jmp _uart0_tx_isr
.area text(rom, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
_dis::
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\12864.h
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\角度傳感器.c
.dbsym e dis _dis A[16:16]c
_i::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\角度傳感器.c
.dbsym e i _i c
.area text(rom, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\角度傳感器.c
.dbfunc e IO_init _IO_init fV
.even
_IO_init::
.dbline -1
.dbline 18
; #include <iom16v.h>
; #include <macros.h>
; #include"12864.h"
; unsigned char tempRece;
; #pragma interrupt_handler uart0_rx_isr:12
; #pragma interrupt_handler uart0_tx_isr:14
; unsigned char dis[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
; char i=0;
;
; /*-----------------------------------------------------------------
; 函數(shù)名稱: void IO_init(void)
; 函數(shù)功能: 端口初始化
; 參 數(shù):
; 返 回 值: 無
; -----------------------------------------------------------------*/
;
; void IO_init(void)
; {
.dbline 19
; DDRD =0X22; //RXD輸入,TXD輸出,PD5輸出
ldi R24,34
out 0x11,R24
.dbline 20
; PORTD=0XFF;
ldi R24,255
out 0x12,R24
.dbline -2
L39:
.dbline 0 ; func end
ret
.dbend
.dbfunc e uart0_rx_isr _uart0_rx_isr fV
.even
_uart0_rx_isr::
.dbline 0 ; func end
reti
.dbend
.dbfunc e uart0_tx_isr _uart0_tx_isr fV
.even
_uart0_tx_isr::
.dbline 0 ; func end
reti
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline 0 ; func end
ret
.dbend
.dbfunc e Usart_init _Usart_init fV
.even
_Usart_init::
.dbline 0 ; func end
ret
.dbend
.dbfunc e Usart_Transmit _Usart_Transmit fV
; i -> R0
.even
_Usart_Transmit::
.dbline 0 ; func end
ret
.dbsym l i 0 c
.dbend
.area bss(ram, con, rel)
.dbfile E:\AVR自編程序\11avr實驗板\22角度~1\角度傳感器.c
_tempRece::
.blkb 1
.dbsym e tempRece _tempRece c
; }
; void uart0_rx_isr(void) //將接收到的數(shù)據(jù)顯示在LED上,同時蜂鳴一聲
; {
; tempRece=UDR;
; (tempRece==''){i=0;}
; dis[i]=tempRece;
; i++;if(i==16)i=0;
; }
; void uart0_tx_isr(void) //數(shù)據(jù)發(fā)送完成后,蜂鳴一聲
; {
; }
; /*-----------------------------------------------------------------
; 函數(shù)名稱: void main(void)
; 函數(shù)功能: 主函數(shù)
; 參 數(shù):
; 返 回 值: 無
; -----------------------------------------------------------------*/
; void main(void)
; {
; unsigned char temp;
; IO_init();
; SEI(); //全局中斷使能
; Usart_init();
; while(1){}
; }
; void Usart_init(void)
; {
; UCSRA=0X02; //倍頻速度
; UCSRB|=(1<<RXCIE)|(1<<TXCIE)|(1<<RXEN)|(1<<TXEN); //使能接收/發(fā)送,接收/發(fā)送結(jié)束中斷使能
; UCSRC|=(1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);//8bit,異步,無奇偶校驗,1個停止位
; UBRR=12; //9600波特率
; }
;
; void Usart_Transmit(unsigned char i)
; {
; while(!(UCSRA&(1<<UDRE))); //判斷UDR是否為空
; UDR=i; //發(fā)送數(shù)據(jù)
;
; }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -