📄 lcd-16sn.s
字号:
.module LCD-16sn.c
.area text(rom, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
_lcd_enable::
.blkb 1
.area idata
.byte 1
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbsym e lcd_enable _lcd_enable c
_lcd_disable::
.blkb 1
.area idata
.byte 254
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbsym e lcd_disable _lcd_disable c
_in_instr_wr::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbsym e in_instr_wr _in_instr_wr c
_in_data_wr::
.blkb 1
.area idata
.byte 4
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbsym e in_data_wr _in_data_wr c
_in_instr_rd::
.blkb 1
.area idata
.byte 2
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbsym e in_instr_rd _in_instr_rd c
_in_data_rd::
.blkb 1
.area idata
.byte 6
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbsym e in_data_rd _in_data_rd c
_indexhead::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbsym e indexhead _indexhead I
_indextail::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbsym e indextail _indextail I
_cursor_index::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbsym e cursor_index _cursor_index I
.area lit(rom, con, rel)
_message1::
.byte 32,32,'R,'S,50,51,50,32,'D,'e,'m,'o,32,32,32,32
.byte 0
.dbsym e message1 _message1 A[17:17]kc
_message2::
.byte 'B,'a,'u,'d,'r,'a,'t,'e,61,51,56,52,48,48,32,32
.byte 0
.dbsym e message2 _message2 A[17:17]kc
_message3::
.byte 32,'H,'a,'p,'p,'y,32,'N,'e,'w,32,'Y,'e,'a,'r,0
.dbsym e message3 _message3 A[16:16]kc
_message4::
.byte 32,50,48,48,56,32,'i,'s,32,'c,'o,'m,'i,'n,'g,0
.dbsym e message4 _message4 A[16:16]kc
_message5::
.byte 32,'G,'r,'e,'e,'t,'i,'n,'g,32,'F,'r,'o,'m,0
.dbsym e message5 _message5 A[15:15]kc
_message6::
.byte 'w,'w,'w,46,'i,'n,'o,'v,'a,'c,'s,46,'c,'o,'m,0
.dbsym e message6 _message6 A[16:16]kc
_message7::
.byte 'C,'o,'n,'t,'a,'c,'t,32,'I,'n,'o,'v,'a,0
.dbsym e message7 _message7 A[14:14]kc
_message8::
.byte 'T,'e,'l,58,48,53,57,50,32,53,53,54,51,53,55,48
.byte 0
.dbsym e message8 _message8 A[17:17]kc
.area text(rom, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
.dbfunc e WDT_off _WDT_off fV
.even
_WDT_off::
.dbline -1
.dbline 39
; /*
; Title: LCD-16sn.c
; Function program used by DEMOB-16sm.c
; */
;
; #include <iom16v.h>
; #include <macros.h>
; #include <stdlib.h>
;
; unsigned char lcd_enable = 0b00000001, lcd_disable = 0b11111110;
; unsigned char in_instr_wr = 0b00000000, in_data_wr = 0b00000100;
; unsigned char in_instr_rd = 0b00000010, in_data_rd = 0b00000110;
;
; void wr_instruction(unsigned char instr);
; void wr_data(unsigned char data);
;
; int indexhead=0, indextail=0, indexcount;
; int cursor_index=0;
;
;
; const char message1[]= {" RS232 Demo "};
; const char message2[]= {"Baudrate=38400 "};
; const char message3[]= {" Happy New Year"};
; const char message4[]= {" 2008 is coming"};
; const char message5[]= {" Greeting From"};
; const char message6[]= {"www.inovacs.com"};
; const char message7[]= {"Contact Inova"};
; const char message8[]= {"Tel:0592 5563570"};
;
; void cursor_home(void);
; void cursor_line1(void);
; void cursor_line2(void);
; int ifr_decode(void);
; unsigned char swin, swin2;
;
; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
; void WDT_off(void)
; {
.dbline 40
; WDR();
wdr
.dbline 41
; WDTCR=0b00010111;
ldi R24,23
out 0x21,R24
.dbline 42
; WDTCR=0b00000111;
ldi R24,7
out 0x21,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e delay _delay fV
; b -> R10,R11
; a -> R20,R21
; count -> R16,R17
.even
_delay::
xcall push_xgset300C
.dbline -1
.dbline 46
; }
;
; void delay(int count)
; {
.dbline 48
; int a,b;
; b=2*count;
movw R10,R16
lsl R10
rol R11
.dbline 49
; for(a=0; a<b; a++)
clr R20
clr R21
xjmp L6
L3:
.dbline 50
; ;
L4:
.dbline 49
subi R20,255 ; offset = 1
sbci R21,255
L6:
.dbline 49
cp R20,R10
cpc R21,R11
brlt L3
X0:
.dbline -2
L2:
.dbline 0 ; func end
xjmp pop_xgset300C
.dbsym r b 10 I
.dbsym r a 20 I
.dbsym r count 16 I
.dbend
.dbfunc e ldelay _ldelay fV
; i -> R20,R21
; ms -> R10,R11
.even
_ldelay::
xcall push_xgset300C
movw R10,R16
.dbline -1
.dbline 54
; }
;
; void ldelay(int ms)
; {
.dbline 56
; int i;
; for(i=0; i<=ms; i++)
clr R20
clr R21
xjmp L11
L8:
.dbline 57
; delay(0x2000); //2000-->4000
ldi R16,8192
ldi R17,32
xcall _delay
L9:
.dbline 56
subi R20,255 ; offset = 1
sbci R21,255
L11:
.dbline 56
cp R10,R20
cpc R11,R21
brge L8
X1:
.dbline -2
L7:
.dbline 0 ; func end
xjmp pop_xgset300C
.dbsym r i 20 I
.dbsym r ms 10 I
.dbend
.dbfunc e wr_instruction _wr_instruction fV
; instr -> R10
.even
_wr_instruction::
st -y,R10
mov R10,R16
.dbline -1
.dbline 70
; }
;
; // ************************************************************
; // LCD functions follows
;
; //PORTB to LCD data port
; //PORTA to LCD control port
; //PA0--> R/S
; //PA1--> R/W
; //PA2--> E
;
; void wr_instruction(unsigned char instr)
; {
.dbline 71
; DDRA=0xff;
ldi R24,255
out 0x1a,R24
.dbline 72
; delay(1);
ldi R16,1
ldi R17,0
xcall _delay
.dbline 73
; PORTA=0b00000000;
clr R2
out 0x1b,R2
.dbline 74
; PORTB=instr; //send out instruction
out 0x18,R10
.dbline 75
; delay(2);
ldi R16,2
ldi R17,0
xcall _delay
.dbline 76
; PORTA=0b00000100; //PA2<--1 LCD-E ON (enable)
ldi R24,4
out 0x1b,R24
.dbline 77
; delay(2);
ldi R16,2
ldi R17,0
xcall _delay
.dbline 78
; PORTA=0b00000000; //PA2<--0 LCD-E OFF (disable)
clr R2
out 0x1b,R2
.dbline 79
; delay(1);
ldi R16,1
ldi R17,0
xcall _delay
.dbline -2
L12:
.dbline 0 ; func end
ld R10,y+
ret
.dbsym r instr 10 c
.dbend
.dbfunc e wr_data _wr_data fV
; data -> R10
.even
_wr_data::
st -y,R10
mov R10,R16
.dbline -1
.dbline 83
; }
;
; void wr_data(unsigned char data)
; {
.dbline 84
; DDRA=0xff;
ldi R24,255
out 0x1a,R24
.dbline 85
; PORTA=0b00000001; //PA0 <-- 1, Select data register
ldi R24,1
out 0x1b,R24
.dbline 86
; PORTB=data; //Send out data
out 0x18,R10
.dbline 87
; delay(1);
ldi R16,1
ldi R17,0
xcall _delay
.dbline 88
; PORTA=0b00000101; //Enable write to Data register
ldi R24,5
out 0x1b,R24
.dbline 89
; delay(2);
ldi R16,2
ldi R17,0
xcall _delay
.dbline 90
; PORTA=0b00000000; //disable ????
clr R2
out 0x1b,R2
.dbline 91
; delay(1);
ldi R16,1
ldi R17,0
xcall _delay
.dbline -2
L13:
.dbline 0 ; func end
ld R10,y+
ret
.dbsym r data 10 c
.dbend
.dbfunc e wr_instruction2 _wr_instruction2 fV
; flags -> <dead>
; instr -> R10
.even
_wr_instruction2::
st -y,R10
mov R10,R16
.dbline -1
.dbline 98
; }
;
; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; // Following functions for LCD panel control
;
; void wr_instruction2(unsigned char instr)
; {
.dbline 100
; unsigned char flags;
; delay(10);
ldi R16,10
ldi R17,0
xcall _delay
.dbline 101
; wr_instruction(instr);
mov R16,R10
xcall _wr_instruction
.dbline 102
; delay(10);
ldi R16,10
ldi R17,0
xcall _delay
.dbline -2
L14:
.dbline 0 ; func end
ld R10,y+
ret
.dbsym l flags 1 c
.dbsym r instr 10 c
.dbend
.dbfunc e wr_data2 _wr_data2 fV
; flags -> <dead>
; data -> R10
.even
_wr_data2::
st -y,R10
mov R10,R16
.dbline -1
.dbline 106
; }
;
; void wr_data2(unsigned char data)
; {
.dbline 108
; unsigned char flags;
; if(cursor_index==0x10)
lds R24,_cursor_index
lds R25,_cursor_index+1
cpi R24,16
ldi R30,0
cpc R25,R30
brne L16
X2:
.dbline 109
; cursor_line2();
xcall _cursor_line2
xjmp L17
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -