?? usart.s
字號:
.module usart.c
.area text(rom, con, rel)
.dbfile E:\新建文件夾\usart_icc\cfile\usart.c
.dbfunc e UsartInit _UsartInit fV
.even
_UsartInit::
.dbline -1
.dbline 4
; #define USART_C
; #include "includes.h"
; void UsartInit(void)
; {
.dbline 12
; // 晶振頻率 : 4.0MHz
; // 通信參數(shù): 8 Data, 1 Stop, No Parity
; // 波特率:
; // UBRRL= 0x0C 19200;
; // UBRRL= 0x19 9600;
; // UBRRL= 0x33 4800;
; // UBRRL= 0x67 2400
; UCSRB |= (1<<RXEN)|(1<<TXEN)|(1<<RXCIE); //允許發(fā)送和接收,接收中斷使能
in R24,0xa
ori R24,152
out 0xa,R24
.dbline 13
; UCSRC |= (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); //8位數(shù)據(jù)位+1位停止位
in R24,0x20
ori R24,134
out 0x20,R24
.dbline 14
; UBRRH = 0x00;
clr R2
out 0x20,R2
.dbline 15
; UBRRL = 0x19;
ldi R24,25
out 0x9,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e PutChar _PutChar fI
; c -> R20
.even
_PutChar::
st -y,R20
mov R20,R16
.dbline -1
.dbline 20
; //sei();
; }
;
; int PutChar(char c)
; {
.dbline 21
; if(c == '\n')
cpi R20,10
brne L3
X0:
.dbline 22
; {
.dbline 23
; PutChar('\r');
ldi R16,13
xcall _PutChar
.dbline 24
; }
L3:
.dbline 25
; UDR = c;
out 0xc,R20
L5:
.dbline 26
; while(!(UCSRA &(1<<UDRE)));
L6:
.dbline 26
sbis 0xb,5
rjmp L5
X1:
.dbline 27
; UCSRA |= (1<<UDRE);
sbi 0xb,5
.dbline 28
; return 0;
clr R16
clr R17
.dbline -2
L2:
.dbline 0 ; func end
ld R20,y+
ret
.dbsym r c 20 c
.dbend
.dbfunc e SendNbyte _SendNbyte fV
; w -> R10
; L -> R12
; p -> R14,R15
.even
_SendNbyte::
xcall push_xgset00FC
mov R12,R18
movw R14,R16
.dbline -1
.dbline 33
; }
;
;
; void SendNbyte(unsigned char *p,unsigned char L)
; {
.dbline 35
; unsigned char w;
; for(w=0;w<L;w++)
clr R10
xjmp L12
L9:
.dbline 36
; {
.dbline 40
; // UDR = *(p+w);
; // while(!(UCSRA &(1<<UDRE)));
; //UCSRA |= (1<<UDRE);
; PutChar(*(p+w));
mov R30,R10
clr R31
add R30,R14
adc R31,R15
ldd R16,z+0
xcall _PutChar
.dbline 41
; }
L10:
.dbline 35
inc R10
L12:
.dbline 35
cp R10,R12
brlo L9
X2:
.dbline -2
L8:
.dbline 0 ; func end
xjmp pop_xgset00FC
.dbsym r w 10 c
.dbsym r L 12 c
.dbsym r p 14 pc
.dbend
.dbfunc e PutStr _PutStr fV
; Str -> R20,R21
.even
_PutStr::
st -y,R20
st -y,R21
movw R20,R16
.dbline -1
.dbline 46
;
; }
;
; void PutStr(unsigned char *Str)
; {
xjmp L15
L14:
.dbline 48
; while(*Str != '\0')
; {
.dbline 49
; PutChar(*Str);
movw R30,R20
ldd R16,z+0
xcall _PutChar
.dbline 50
; Str++;
subi R20,255 ; offset = 1
sbci R21,255
.dbline 51
; }
L15:
.dbline 47
movw R30,R20
ldd R2,z+0
tst R2
brne L14
X3:
.dbline -2
L13:
.dbline 0 ; func end
ld R21,y+
ld R20,y+
ret
.dbsym r Str 20 pc
.dbend
; }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -