📄 new_disp.s
字号:
.module new_disp.c
.area lit(rom, con, rel)
_S::
.byte 175,6
.byte 'm,'O
.byte 198,203
.byte 235,14
.byte 239,207
.byte 0
.dbfile D:\avr\avr_program\disp_88i\new_disp.c
.dbsym e S _S A[11:11]kc
.area text(rom, con, rel)
.dbfile D:\avr\avr_program\disp_88i\new_disp.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 25
; #include "iom88v.h"
;
; #define SS PB2
; #define MOSI PB3
; #define SCK PB5
;
; #define _asm asm
; #define WDR() asm("wdr")
; #define SEI() asm("sei")
; #define CLI() asm("cli")
;
; #define a1 0x04
; #define a2 0x0c
; #define a3 0x14
; #define a4 0x1c
; #define a5 0x24
; #define a6 0x2c
; #define a7 0x34
; #define a8 0x3c
; #define a9 0x44
;
; const char S[11]={0xaf,0x06,0x6d,0x4f,0xc6,0xcb,0xeb,0x0e,0xef,0xcf,0x00};
;
; void port_init(void)//口方向设置
; {
.dbline 26
; DDRB = 0xff;
ldi R24,255
out 0x4,R24
.dbline 27
; DDRC = 0X00;
clr R2
out 0x7,R2
.dbline 28
; PORTC=0xff;
out 0x8,R24
.dbline 29
; DDRD = 0x00;
out 0xa,R2
.dbline 30
; PORTD=0xff;
out 0xb,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e delay_us _delay_us fV
; time -> R16,R17
.even
_delay_us::
.dbline -1
.dbline 33
; }
; void delay_us(int time)//微秒级延时程序
; {
L3:
.dbline 35
; do
; {
.dbline 36
; time--;
subi R16,1
sbci R17,0
.dbline 37
; }
L4:
.dbline 38
; while (time>1);
ldi R24,1
ldi R25,0
cp R24,R16
cpc R25,R17
brlt L3
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbsym r time 16 I
.dbend
.dbfunc e delay_ms _delay_ms fV
; time -> R10,R11
.even
_delay_ms::
rcall push_gset3x
movw R10,R16
.dbline -1
.dbline 41
; }
; void delay_ms(unsigned int time)//毫秒级延时程序
; {
rjmp L8
L7:
.dbline 43
.dbline 44
ldi R16,1000
ldi R17,3
rcall _delay_us
.dbline 45
movw R24,R10
sbiw R24,1
movw R10,R24
.dbline 46
L8:
.dbline 42
; while(time!=0)
tst R10
brne L7
tst R11
brne L7
X0:
.dbline -2
L6:
rcall pop_gset3x
.dbline 0 ; func end
ret
.dbsym r time 10 i
.dbend
.dbfunc e SendBit _SendBit fV
; i -> R10
; bitcnt -> R12
; dat -> R14
.even
_SendBit::
rcall push_gset5x
mov R12,R18
mov R14,R16
.dbline -1
.dbline 54
; {
; delay_us(1000);
; time--;
; }
; }/*
; void Delay()
; {
; unsigned char i;
; for(i=0;i<10;i++); /*用于调整CLK 脉冲宽度*/
; //}
; void SendBit(unsigned char dat,unsigned char bitcnt)
; {
.dbline 56
; unsigned char i;
; CLI();
cli
.dbline 57
; for(i=0;i<bitcnt;i++)
clr R10
rjmp L14
L11:
.dbline 58
; {
.dbline 59
; if(( dat & 0X80 ) == 0)
sbrc R14,7
rjmp L15
.dbline 60
; PORTB &=(~(1<<MOSI));
cbi 0x5,3
rjmp L16
L15:
.dbline 62
; else
; PORTB |=(1<<MOSI); /*发送数据由高位到低位传送*/
sbi 0x5,3
L16:
.dbline 64
ldi R16,10
ldi R17,0
rcall _delay_us
.dbline 65
sbi 0x5,5
.dbline 67
ldi R16,10
ldi R17,0
rcall _delay_us
.dbline 68
cbi 0x5,5
.dbline 69
lsl R14
.dbline 70
L12:
.dbline 57
inc R10
L14:
.dbline 57
cp R10,R12
brlo L11
.dbline 71
; //Delay();
; delay_us(10);
; PORTB |=(1<<SCK); /*置时钟线为高通知被控器开始接收数位*/
; //Delay();
; delay_us(10);
; PORTB &=(~(1<<SCK)); /*钳住总线准备下一个数据位*/
; dat=dat<<1; /*发送数据左移一位*/
; }
; SEI();
sei
.dbline -2
L10:
rcall pop_gset5x
.dbline 0 ; func end
ret
.dbsym r i 10 c
.dbsym r bitcnt 12 c
.dbsym r dat 14 c
.dbend
.dbfunc e Start_spi _Start_spi fV
.even
_Start_spi::
.dbline -1
.dbline 75
; }
;
; void Start_spi()
; {
.dbline 76
; PORTB |=(1<<SS);
sbi 0x5,2
.dbline 77
; PORTB |=(1<<SCK);
sbi 0x5,5
.dbline 78
; PORTB |=(1<<MOSI);
sbi 0x5,3
.dbline 80
; //Delay();
; delay_us(10);
ldi R16,10
ldi R17,0
rcall _delay_us
.dbline 81
; PORTB &=(~(1<<SS));PORTB &=(~(1<<SS));
cbi 0x5,2
.dbline 81
cbi 0x5,2
.dbline 82
; PORTB &=(~(1<<SCK));PORTB &=(~(1<<SCK));
cbi 0x5,5
.dbline 82
cbi 0x5,5
.dbline -2
L17:
.dbline 0 ; func end
ret
.dbend
.dbfunc e SendByte _SendByte fV
; dat -> R10
.even
_SendByte::
rcall push_gset3x
mov R10,R16
.dbline -1
.dbline 86
; }
;
; void SendByte(unsigned char dat)
; {
.dbline 87
; SendBit(dat,8); /*发送字节*/
ldi R18,8
mov R16,R10
rcall _SendBit
.dbline -2
L18:
rcall pop_gset3x
.dbline 0 ; func end
ret
.dbsym r dat 10 c
.dbend
.dbfunc e SENDCOMA _SENDCOMA fV
; com -> R10
.even
_SENDCOMA::
rcall push_gset3x
mov R10,R16
.dbline -1
.dbline 91
; }
;
; void SENDCOMA(unsigned char com)
; {
.dbline 92
; Start_spi();
rcall _Start_spi
.dbline 93
; SendBit(0X80,4); //*发送设置命令ID=100 0*
ldi R18,4
ldi R16,128
rcall _SendBit
.dbline 94
; SendByte(com); //*发送命令字*
mov R16,R10
rcall _SendByte
.dbline -2
L19:
rcall pop_gset3x
.dbline 0 ; func end
ret
.dbsym r com 10 c
.dbend
.dbfunc e SENDCOMB _SENDCOMB fV
; adr -> R10
.even
_SENDCOMB::
rcall push_gset3x
mov R10,R16
.dbline -1
.dbline 98
; }
;
; void SENDCOMB(unsigned char adr)
; {
.dbline 99
; Start_spi();
rcall _Start_spi
.dbline 100
; SendBit(0XA0,3); /*发送写显示RAM 命令ID=101 */
ldi R18,3
ldi R16,160
rcall _SendBit
.dbline 101
; SendBit(adr,6); /*指定写入地址*/
ldi R18,6
mov R16,R10
rcall _SendBit
.dbline -2
L20:
rcall pop_gset3x
.dbline 0 ; func end
ret
.dbsym r adr 10 c
.dbend
.dbfunc e disp_init _disp_init fV
; i -> R10
.even
_disp_init::
rcall push_gset3x
.dbline -1
.dbline 104
; }
; void disp_init(void)
; {
.dbline 106
; unsigned char i;
; SENDCOMA(0X0a); /*禁止WDT溢出标志输出*/
ldi R16,10
rcall _SENDCOMA
.dbline 107
; SENDCOMA(0X52); //设置偏压,背极数 定义1/3 偏压4背极
ldi R16,82
rcall _SENDCOMA
.dbline 108
; SENDCOMA(0X30); //*使用内部256KRC 振荡器*
ldi R16,48
rcall _SENDCOMA
.dbline 109
; SENDCOMA(0X02); //*启动振荡器*
ldi R16,2
rcall _SENDCOMA
.dbline 110
; SENDCOMA(0X06); //LCDON
ldi R16,6
rcall _SENDCOMA
.dbline 111
; SENDCOMA(0X08);//timer dis
ldi R16,8
rcall _SENDCOMA
.dbline 112
; SENDCOMB(0x00); //*把数据指针指回0 接着写入数据*
clr R16
rcall _SENDCOMB
.dbline 113
; for(i=0;i<15;i++) /*写入16 字节数据*/
clr R10
rjmp L25
L22:
.dbline 114
.dbline 115
clr R16
rcall _SendByte
.dbline 116
L23:
.dbline 113
inc R10
L25:
.dbline 113
mov R24,R10
cpi R24,15
brlo L22
.dbline -2
L21:
rcall pop_gset3x
.dbline 0 ; func end
ret
.dbsym r i 10 c
.dbend
.dbfunc e disp_off _disp_off fV
.even
_disp_off::
.dbline -1
.dbline 119
; {
; SendByte(0x0); /*写入数据*/
; }
; }
; void disp_off(void)
; {
.dbline 120
; SENDCOMA(0X04);//lcdoff
ldi R16,4
rcall _SENDCOMA
.dbline 121
; SENDCOMA(0X00);//sys dis
clr R16
rcall _SENDCOMA
.dbline -2
L26:
.dbline 0 ; func end
ret
.dbend
.dbfunc e disp _disp fV
; dat -> R10
; add -> R12
.even
_disp::
rcall push_gset5x
mov R10,R18
mov R12,R16
.dbline -1
.dbline 125
; //SENDCOMA(0X0c);//timer en
; }
; void disp(char add,char dat)
; {
.dbline 126
; switch(add)
mov R14,R12
clr R15
movw R24,R14
cpi R24,1
ldi R30,0
cpc R25,R30
breq L31
cpi R24,2
ldi R30,0
cpc R25,R30
breq L32
cpi R24,3
ldi R30,0
cpc R25,R30
breq L33
cpi R24,4
ldi R30,0
cpc R25,R30
breq L34
cpi R24,5
ldi R30,0
cpc R25,R30
breq L35
cpi R24,6
ldi R30,0
cpc R25,R30
breq L36
cpi R24,7
ldi R30,0
cpc R25,R30
breq L37
cpi R24,8
ldi R30,0
cpc R25,R30
breq L38
cpi R24,9
ldi R30,0
cpc R25,R30
breq L39
rjmp L28
X1:
.dbline 127
; {
L31:
.dbline 128
; case 1: add=a1;break;
ldi R24,4
mov R12,R24
.dbline 128
rjmp L29
L32:
.dbline 129
; case 2: add=a2;break;
ldi R24,12
mov R12,R24
.dbline 129
rjmp L29
L33:
.dbline 130
; case 3: add=a3;break;
ldi R24,20
mov R12,R24
.dbline 130
rjmp L29
L34:
.dbline 131
; case 4: add=a4;break;
ldi R24,28
mov R12,R24
.dbline 131
rjmp L29
L35:
.dbline 132
; case 5: add=a5;break;
ldi R24,36
mov R12,R24
.dbline 132
rjmp L29
L36:
.dbline 133
; case 6: add=a6;break;
ldi R24,44
mov R12,R24
.dbline 133
rjmp L29
L37:
.dbline 134
; case 7: add=a7;break;
ldi R24,52
mov R12,R24
.dbline 134
rjmp L29
L38:
.dbline 135
; case 8: add=a8;break;
ldi R24,60
mov R12,R24
.dbline 135
rjmp L29
L39:
.dbline 136
; case 9: add=a9;break;
ldi R24,68
mov R12,R24
.dbline 136
L28:
L29:
.dbline 138
; }
; SENDCOMB(add); //write address
mov R16,R12
rcall _SENDCOMB
.dbline 139
; SendByte(S[dat]); //write data
ldi R24,<_S
ldi R25,>_S
mov R30,R10
clr R31
add R30,R24
adc R31,R25
lpm R16,Z
rcall _SendByte
.dbline -2
L27:
rcall pop_gset5x
.dbline 0 ; func end
ret
.dbsym r dat 10 c
.dbsym r add 12 c
.dbend
.dbfunc e main _main fV
; j -> R10
; i -> R12
.even
_main::
.dbline -1
.dbline 143
; //SendByte(S[dat]); //write data
; }
; void main(void)
; {
.dbline 145
; char i,j;
; port_init();
rcall _port_init
.dbline 146
; disp_init();
rcall _disp_init
.dbline 147
clr R12
inc R12
clr R10
inc R10
rjmp L44
L41:
.dbline 147
mov R18,R10
mov R16,R12
rcall _disp
L42:
.dbline 147
inc R12
inc R10
L44:
.dbline 147
; for(i=1,j=1;i<10;i++,j++) disp(i,j);
mov R24,R12
cpi R24,10
brlo L41
L45:
.dbline 149
L46:
.dbline 149
rjmp L45
X2:
.dbline -2
L40:
.dbline 0 ; func end
ret
.dbsym r j 10 c
.dbsym r i 12 c
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -