?? icc.s
字號:
.module icc.c
.area text(rom, con, rel)
.dbfile D:\sl279\test\ICCAVR\icc.c
.dbfunc s receive_byte _receive_byte fI
; i -> R20
; temp -> R22
.even
_receive_byte::
rcall push_gset2
.dbline -1
.dbline 14
; /************************************************************/
; /* 廣州天河雙龍電子有限公司 */
; /* http://www.sl.com.cn */
; /* SL279鍵盤與LED顯示控制芯片演示程序(ICCAVR版本) */
; /* 程序作者:詹衛(wèi)前 */
; /*接線方式:CS=PORTC.4 CLK=PORTC.3 DATA=PORTC.2 KEY=PORTC.1 */
; /* 處理器:AT90S8515 晶振頻率:8MHZ */
; /* SL279 晶振頻率:12MHZ 使用SLAVR庫 */
; /************************************************************/
; #include<io8515.h>
; #include<slavr.h>
; /* 字節(jié)接收函數(shù) */
; unsigned char receive_byte(void)
; {
.dbline 15
; unsigned char i,temp=0;
clr R22
.dbline 16
; DDRC&=0xfb;
in R24,0x14
andi R24,251
out 0x14,R24
.dbline 17
; delay_us(90);
ldi R16,90
ldi R17,0
rcall _delay_us
.dbline 18
; for(i=0;i<8;i++)
clr R20
rjmp L5
L2:
.dbline 19
; {
.dbline 20
; temp=temp<<1;
lsl R22
.dbline 21
; PORTC|=0x08;//clk=1
sbi 0x15,3
.dbline 22
; delay_us(10);
ldi R16,10
ldi R17,0
rcall _delay_us
.dbline 23
; if((PINC&0x04)!=0)
sbis 0x13,2
rjmp L6
.dbline 24
; temp|=0x01;
ori R22,1
L6:
.dbline 25
in R24,0x15
andi R24,247
out 0x15,R24
.dbline 26
ldi R16,10
ldi R17,0
rcall _delay_us
.dbline 27
L3:
.dbline 18
inc R20
L5:
.dbline 18
cpi R20,8
brlo L2
.dbline 28
; PORTC&=0xf7;//clk=0
; delay_us(10);
; }
; DDRC|=0x04;
sbi 0x14,2
.dbline 29
; return temp;
mov R16,R22
clr R17
.dbline -2
L1:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r temp 22 c
.dbfunc s send_byte _send_byte fI
; i -> R20
; para -> R22
.even
_send_byte::
rcall push_gset2
mov R22,R16
.dbline -1
.dbline 33
; }
; /* 字節(jié)發(fā)送函數(shù) */
; void send_byte(unsigned char para)
; {
.dbline 35
; unsigned char i;
; PORTC&=0xef;//cs=0
in R24,0x15
andi R24,239
out 0x15,R24
.dbline 36
; delay_us(90);
ldi R16,90
ldi R17,0
rcall _delay_us
.dbline 37
; for(i=0;i<8;i++)
clr R20
rjmp L12
L9:
.dbline 38
; {
.dbline 39
; if((para&0x80)==0x80)
mov R24,R22
andi R24,128
cpi R24,128
brne L13
.dbline 40
; PORTC|=0x04;//data=1
sbi 0x15,2
rjmp L14
L13:
.dbline 42
; else
; PORTC&=0xfb;//data=0
in R24,0x15
andi R24,251
out 0x15,R24
L14:
.dbline 43
sbi 0x15,3
.dbline 44
ldi R16,10
ldi R17,0
rcall _delay_us
.dbline 45
in R24,0x15
andi R24,247
out 0x15,R24
.dbline 46
ldi R16,10
ldi R17,0
rcall _delay_us
.dbline 47
lsl R22
.dbline 48
L10:
.dbline 37
inc R20
L12:
.dbline 37
cpi R20,8
brlo L9
.dbline -2
.dbline 49
; PORTC|=0x08;//clk=1
; delay_us(10);
; PORTC&=0xf7;//clk=0
; delay_us(10);
; para=para<<1;
; }
; }
L8:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r para 22 c
.dbfunc s write279 _write279 fI
; cmd2 -> R20
; cmd1 -> R22
.even
_write279::
rcall push_gset2
mov R20,R18
mov R22,R16
.dbline -1
.dbline 52
; /* 寫sl279雙字節(jié)命令 */
; void write279(unsigned char cmd1, unsigned char cmd2)
; {
.dbline 53
; send_byte (cmd1);
mov R16,R22
rcall _send_byte
.dbline 54
; send_byte (cmd2);
mov R16,R20
rcall _send_byte
.dbline 55
; PORTC|=0x10;
sbi 0x15,4
.dbline -2
.dbline 56
; }
L15:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r cmd2 20 c
.dbsym r cmd1 22 c
.dbfunc s test1 _test1 fI
; cmd -> R20
.even
_test1::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 58
; void test1(unsigned char cmd)
; {
.dbline 59
; send_byte(cmd);
mov R16,R20
rcall _send_byte
.dbline 60
; PORTC|=0x10;
sbi 0x15,4
.dbline 61
; delay_ms(3000);
ldi R16,3000
ldi R17,11
rcall _delay_ms
.dbline -2
.dbline 62
; }
L16:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r cmd 20 c
.dbfunc s mcu_init _mcu_init fI
.even
_mcu_init::
.dbline -1
.dbline 65
; /* MCU初始化 */
; void mcu_init(void)
; {
.dbline 66
; MCUCR=0x00;
clr R2
out 0x35,R2
.dbline 67
; DDRC=0xfd;
ldi R24,253
out 0x14,R24
.dbline 68
; PORTC=0xf3;
ldi R24,243
out 0x15,R24
.dbline -2
.dbline 69
; }
L17:
.dbline 0 ; func end
ret
.dbfunc s main _main fI
; count -> R20
; temp -> R22
; i -> R10
.even
_main::
.dbline -1
.dbline 72
; /*
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -