📄 pp.s
字号:
.module pp.c
.area lit(rom, con, rel)
_table_1::
.byte 32,32,32,32,'W,'E,'L,'C,'O,'M,'E,33,0
.dbfile I:\刷卡器/define.h
.dbsym e table_1 _table_1 A[13:13]kc
_table_2::
.byte 'F,'D,'L,'K,'F,'L,'D,'L,'F,0
.dbsym e table_2 _table_2 A[10:10]kc
_readcal1::
.byte 170,187
.byte 10,33
.byte 0,1
.byte 255,255
.byte 255,255
.byte 255,255
.byte 42
.dbsym e readcal1 _readcal1 A[13:13]kc
_writecal1::
.byte 170,187
.byte 26,34
.byte 0,1
.byte 255,255
.byte 255,255
.byte 255,255
.dbsym e writecal1 _writecal1 A[12:12]kc
_writecal2::
.byte 'P,'i,'d,'a,'n,32,32,50,50,57,49,51,54,48,49,32
.byte 0
.dbsym e writecal2 _writecal2 A[17:17]kc
_Name::
.byte 'N,'A,'M,'E,58,0
.dbsym e Name _Name A[6:6]kc
_Num::
.byte 'N,'U,'M,58,0
.dbsym e Num _Num A[5:5]kc
.area text(rom, con, rel)
.dbfile I:\刷卡器/define.h
.dbfile I:\刷卡器\pp.c
.dbfunc e WriteDataLCM _WriteDataLCM fV
; WDLCM -> R20
.even
_WriteDataLCM::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 7
; /*****************0XDFE4*****************************库定义*/
; #include <iom8v.h>
; #include <macros.h>
; #include "define.h"
; //*******************************************************************写数据11//
; void WriteDataLCM(unsigned char WDLCM)
; {
.dbline 8
; ReadStatusLCM(); //检测忙
rcall _ReadStatusLCM
.dbline 9
; PORTB = WDLCM;
out 0x18,R20
.dbline 10
; SET_LCD_RS;CLR_LCD_RW;SET_LCD_RS;CLR_LCD_RW;
sbi 0x12,5
.dbline 10
cbi 0x12,6
.dbline 10
sbi 0x12,5
.dbline 10
cbi 0x12,6
.dbline 11
; CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;
cbi 0x12,7
.dbline 11
cbi 0x12,7
.dbline 11
cbi 0x12,7
.dbline 11
cbi 0x12,7
.dbline 11
cbi 0x12,7
.dbline 11
cbi 0x12,7
.dbline 12
; SET_LCD_E;SET_LCD_E;
sbi 0x12,7
.dbline 12
sbi 0x12,7
.dbline -2
L1:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r WDLCM 20 c
.dbend
.dbfunc e WriteCommandLCM _WriteCommandLCM fV
; BuysC -> R22
; WCLCM -> R20
.even
_WriteCommandLCM::
rcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 16
; }
; //********************************************************************写指令12//
; void WriteCommandLCM(unsigned char WCLCM,unsigned char BuysC) //BuysC为0时忽略忙检测
; {
.dbline 17
; if (BuysC) ReadStatusLCM(); //根据需要检测忙
tst R22
breq L3
.dbline 17
rcall _ReadStatusLCM
L3:
.dbline 18
; PORTB = WCLCM;
out 0x18,R20
.dbline 19
; CLR_LCD_RS;CLR_LCD_RW;
cbi 0x12,5
.dbline 19
cbi 0x12,6
.dbline 20
; CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;
cbi 0x12,7
.dbline 20
cbi 0x12,7
.dbline 20
cbi 0x12,7
.dbline 20
cbi 0x12,7
.dbline 20
cbi 0x12,7
.dbline 20
cbi 0x12,7
.dbline 21
; SET_LCD_E;SET_LCD_E;
sbi 0x12,7
.dbline 21
sbi 0x12,7
.dbline -2
L2:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r BuysC 22 c
.dbsym r WCLCM 20 c
.dbend
.dbfunc e ReadStatusLCM _ReadStatusLCM fc
.even
_ReadStatusLCM::
.dbline -1
.dbline 25
; }
; //*******************************************************************读状态13//
; unsigned char ReadStatusLCM(void)
; {
.dbline 26
; DDRB=0x00; //输入
clr R2
out 0x17,R2
.dbline 27
; CLR_LCD_RS;SET_LCD_RW;
cbi 0x12,5
.dbline 27
sbi 0x12,6
.dbline 28
; CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;CLR_LCD_E;
cbi 0x12,7
.dbline 28
cbi 0x12,7
.dbline 28
cbi 0x12,7
.dbline 28
cbi 0x12,7
.dbline 28
cbi 0x12,7
.dbline 28
cbi 0x12,7
.dbline 29
; SET_LCD_E;SET_LCD_E;
sbi 0x12,7
.dbline 29
sbi 0x12,7
L6:
.dbline 30
L7:
.dbline 30
; while (PINB&0x80); //检测忙信号
sbic 0x16,7
rjmp L6
.dbline 31
; DDRB=0xff;//变回输出
ldi R24,255
out 0x17,R24
.dbline 32
; return(PINB);
in R16,0x16
.dbline -2
L5:
.dbline 0 ; func end
ret
.dbend
.dbfunc e DisplayOneChar _DisplayOneChar fV
; DData -> y+4
; Y -> R22
; X -> R20
.even
_DisplayOneChar::
rcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 36
; }
; //*************************************************************显示一个字符14//
; void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData)
; {
.dbline 37
; Y &= 0x1; X &= 0xF;
andi R22,1
.dbline 37
andi R20,15
.dbline 38
; if (Y) X |= 0x40;
tst R22
breq L10
.dbline 38
ori R20,64
L10:
.dbline 39
; X |= 0x80;
ori R20,128
.dbline 40
; WriteCommandLCM(X, 1);
ldi R18,1
mov R16,R20
rcall _WriteCommandLCM
.dbline 41
; WriteDataLCM(DData);
ldd R16,y+4
rcall _WriteDataLCM
.dbline 42
; WriteCommandLCM(X, 1);
ldi R18,1
mov R16,R20
rcall _WriteCommandLCM
.dbline -2
L9:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym l DData 4 c
.dbsym r Y 22 c
.dbsym r X 20 c
.dbend
.dbfunc e DisplayListChar _DisplayListChar fV
; j -> R20
; Leng -> R22
; DData -> R10,R11
; Y -> R12
; X -> R14
.even
_DisplayListChar::
rcall push_gset5
mov R12,R18
mov R14,R16
sbiw R28,1
ldd R10,y+11
ldd R11,y+12
ldd R22,y+13
.dbline -1
.dbline 46
; }
; //************************************************************显示ROM字符串15//
; void DisplayListChar(unsigned char X, unsigned char Y, const unsigned char *DData,unsigned char Leng)
; {
.dbline 48
; unsigned char j;
; Y &= 0x01;X &= 0x0F;
mov R24,R12
andi R24,1
mov R12,R24
.dbline 48
mov R24,R14
andi R24,15
mov R14,R24
.dbline 49
; for(j=0;j<Leng;X++,j++)
clr R20
rjmp L16
L13:
.dbline 50
; {
.dbline 51
; if(X<=0xf)DisplayOneChar(X,Y,DData[j]);
ldi R24,15
cp R24,R14
brlo L17
.dbline 51
mov R30,R20
clr R31
add R30,R10
adc R31,R11
lpm R30,Z
std y+0,R30
mov R18,R12
mov R16,R14
rcall _DisplayOneChar
L17:
.dbline 52
L14:
.dbline 49
inc R14
inc R20
L16:
.dbline 49
cp R20,R22
brlo L13
.dbline -2
L12:
adiw R28,1
rcall pop_gset5
.dbline 0 ; func end
ret
.dbsym r j 20 c
.dbsym r Leng 22 c
.dbsym r DData 10 pkc
.dbsym r Y 12 c
.dbsym r X 14 c
.dbend
.dbfunc e DisplayListChar1 _DisplayListChar1 fV
; j -> R20
; Leng -> R22
; DData -> R10,R11
; Y -> R12
; X -> R14
.even
_DisplayListChar1::
rcall push_gset5
mov R12,R18
mov R14,R16
sbiw R28,1
ldd R10,y+11
ldd R11,y+12
ldd R22,y+13
.dbline -1
.dbline 56
; }
; }
; //************************************************************显示RAM字符串16//
; void DisplayListChar1(unsigned char X, unsigned char Y, unsigned char *DData,unsigned char Leng)
; {
.dbline 58
; unsigned char j;
; Y &= 0x01;X &= 0x0F;
mov R24,R12
andi R24,1
mov R12,R24
.dbline 58
mov R24,R14
andi R24,15
mov R14,R24
.dbline 59
; for(j=0;j<Leng;X++,j++)
clr R20
rjmp L23
L20:
.dbline 60
; {
.dbline 61
; if(X<=0xf)DisplayOneChar(X,Y,DData[j]);
ldi R24,15
cp R24,R14
brlo L24
.dbline 61
mov R30,R20
clr R31
add R30,R10
adc R31,R11
ldd R2,z+0
std y+0,R2
mov R18,R12
mov R16,R14
rcall _DisplayOneChar
L24:
.dbline 62
L21:
.dbline 59
inc R14
inc R20
L23:
.dbline 59
cp R20,R22
brlo L20
.dbline -2
L19:
adiw R28,1
rcall pop_gset5
.dbline 0 ; func end
ret
.dbsym r j 20 c
.dbsym r Leng 22 c
.dbsym r DData 10 pc
.dbsym r Y 12 c
.dbsym r X 14 c
.dbend
.dbfunc e LCMInit _LCMInit fV
.even
_LCMInit::
.dbline -1
.dbline 66
; }
; }
; //****************************************************************LCM初始化17//
; void LCMInit(void)
; {
.dbline 67
; PORTB = 0;
clr R2
out 0x18,R2
.dbline 68
; WriteCommandLCM(0x38,0); //三次显示模式设置,不检测忙信号
clr R18
ldi R16,56
rcall _WriteCommandLCM
.dbline 69
; delay_ms(5);
ldi R16,5
ldi R17,0
rcall _delay_ms
.dbline 70
; WriteCommandLCM(0x38,0);
clr R18
ldi R16,56
rcall _WriteCommandLCM
.dbline 71
; delay_ms(5);
ldi R16,5
ldi R17,0
rcall _delay_ms
.dbline 72
; WriteCommandLCM(0x38,0);
clr R18
ldi R16,56
rcall _WriteCommandLCM
.dbline 73
; delay_ms(5);
ldi R16,5
ldi R17,0
rcall _delay_ms
.dbline 74
; WriteCommandLCM(0x38,1); //显示模式设置,开始要求每次检测忙信号
ldi R18,1
ldi R16,56
rcall _WriteCommandLCM
.dbline 75
; WriteCommandLCM(0x08,1); //关闭显示
ldi R18,1
ldi R16,8
rcall _WriteCommandLCM
.dbline 76
; WriteCommandLCM(0x01,1); //显示清屏
ldi R18,1
ldi R16,1
rcall _WriteCommandLCM
.dbline 77
; WriteCommandLCM(0x06,1); // 显示光标移动设置
ldi R18,1
ldi R16,6
rcall _WriteCommandLCM
.dbline 78
; WriteCommandLCM(0x0C,1); // 显示开及光标设置
ldi R18,1
ldi R16,12
rcall _WriteCommandLCM
.dbline -2
L26:
.dbline 0 ; func end
ret
.dbend
.dbfunc e RxUart _RxUart fV
.even
_RxUart::
.dbline -1
.dbline 84
; }
;
; //***************************************************中断任务//
; //*************************************************************接收串口数据21//
; void RxUart(void)
; {
.dbline 85
; switch(RxUartAddr)
lds R16,_RxUartAddr
clr R17
cpi R16,0
cpc R16,R17
breq L31
X0:
cpi R16,1
ldi R30,0
cpc R17,R30
breq L32
cpi R16,2
ldi R30,0
cpc R17,R30
breq L33
rjmp L28
X1:
.dbline 86
; {
L31:
.dbline 88
; case(0)://接收关闭
; {
.dbline 89
; RxUartTemp=UDR;RxUartAddr=0;return;
in R2,0xc
sts _RxUartTemp,R2
.dbline 89
clr R2
sts _RxUartAddr,R2
.dbline 89
rjmp L27
L32:
.dbline 92
; }
; case(1)://接收初始
; {
.dbline 93
; RxUartLeng=0;RxUartDely=200;RxUartAddr=2;return;
clr R2
clr R3
sts _RxUartLeng+1,R3
sts _RxUartLeng,R2
.dbline 93
ldi R24,200
ldi R25,0
sts _RxUartDely+1,R25
sts _RxUartDely,R24
.dbline 93
ldi R24,2
sts _RxUartAddr,R24
.dbline 93
rjmp L27
L33:
.dbline 96
; }
; case(2)://接收处理
; {
.dbline 97
; if((UCSRA)&(1<<RXC))
sbis 0xb,7
rjmp L34
.dbline 98
; {
.dbline 99
; RxUartTemp=UDR;RxUartWait=2;RxUartDely=100;
in R2,0xc
sts _RxUartTemp,R2
.dbline 99
ldi R24,2
ldi R25,0
sts _RxUartWait+1,R25
sts _RxUartWait,R24
.dbline 99
ldi R24,100
sts _RxUartDely+1,R25
sts _RxUartDely,R24
.dbline 100
; if(RxUartLeng>=250) return;
lds R24,_RxUartLeng
lds R25,_RxUartLeng+1
cpi R24,250
ldi R30,0
cpc R25,R30
brlo L36
.dbline 100
rjmp L27
L36:
.dbline 101
; RxUartDbuf[RxUartLeng++]=RxUartTemp;
lds R2,_RxUartLeng
lds R3,_RxUartLeng+1
movw R24,R2
adiw R24,1
sts _RxUartLeng+1,R25
sts _RxUartLeng,R24
ldi R24,<_RxUartDbuf
ldi R25,>_RxUartDbuf
movw R30,R2
add R30,R24
adc R31,R25
lds R2,_RxUartTemp
std z+0,R2
.dbline 102
; return;
rjmp L27
L34:
.dbline 105
; }
; else
; {
.dbline 106
; if(!RxUartWait) return;
lds R2,_RxUartWait
lds R3,_RxUartWait+1
tst R2
brne L38
tst R3
brne L38
X2:
.dbline 106
rjmp L27
L38:
.dbline 107
; if(--RxUartDely) return;
lds R24,_RxUartDely
lds R25,_RxUartDely+1
sbiw R24,1
sts _RxUartDely+1,R25
sts _RxUartDely,R24
cpi R24,0
cpc R24,R25
breq L40
X3:
.dbline 107
rjmp L27
L40:
.dbline 108
; RxUartDely=200;
ldi R24,200
ldi R25,0
sts _RxUartDely+1,R25
sts _RxUartDely,R24
.dbline 109
; if(--RxUartWait) return;
lds R24,_RxUartWait
lds R25,_RxUartWait+1
sbiw R24,1
sts _RxUartWait+1,R25
sts _RxUartWait,R24
cpi R24,0
cpc R24,R25
breq L42
X4:
.dbline 109
rjmp L27
L42:
.dbline 110
clr R2
sts _RxUartAddr,R2
.dbline 110
L28:
.dbline -2
L27:
.dbline 0 ; func end
ret
.dbend
.dbfunc e OutLed _OutLed fV
.even
_OutLed::
.dbline -1
.dbline 117
; RxUartAddr=0;return;
; }
; }
; }
; }
; //***************************************************************输出三色灯22//
; void OutLed(void)
; {
.dbline 118
; switch(OutLedAddr)
lds R16,_OutLedAddr
clr R17
cpi R16,0
cpc R16,R17
breq L48
X5:
cpi R16,1
ldi R30,0
cpc R17,R30
breq L49
cpi R16,2
ldi R30,0
cpc R17,R30
breq L52
cpi R16,3
ldi R30,0
cpc R17,R30
brne X7
rjmp L55
X7:
rjmp L45
X6:
.dbline 119
; {
L48:
.dbline 121
; case(0)://停止闪烁
; {
.dbline 122
; OutLedAddr=0;return;
clr R2
sts _OutLedAddr,R2
.dbline 122
rjmp L44
L49:
.dbline 125
; }
; case(1)://绿灯闪
; {
.dbline 126
; if(++OutLedDely<1000) return;
lds R24,_OutLedDely
lds R25,_OutLedDely+1
adiw R24,1
sts _OutLedDely+1,R25
sts _OutLedDely,R24
cpi R24,232
ldi R30,3
cpc R25,R30
brsh L50
.dbline 126
rjmp L44
L50:
.dbline 127
; OutLedDely=0;PORTC|=0x08;PORTC^=0x06;return;
clr R2
clr R3
sts _OutLedDely+1,R3
sts _OutLedDely,R2
.dbline 127
sbi 0x15,3
.dbline 127
ldi R24,6
in R2,0x15
eor R2,R24
out 0x15,R2
.dbline 127
rjmp L44
L52:
.dbline 130
; }
; case(2)://红灯闪
; {
.dbline 131
; if(++OutLedDely<1000) return;
lds R24,_OutLedDely
lds R25,_OutLedDely+1
adiw R24,1
sts _OutLedDely+1,R25
sts _OutLedDely,R24
cpi R24,232
ldi R30,3
cpc R25,R30
brsh L53
.dbline 131
rjmp L44
L53:
.dbline 132
; OutLedDely=0;PORTC|=0x06;PORTC^=0x08;return;
clr R2
clr R3
sts _OutLedDely+1,R3
sts _OutLedDely,R2
.dbline 132
in R24,0x15
ori R24,6
out 0x15,R24
.dbline 132
ldi R24,8
in R2,0x15
eor R2,R24
out 0x15,R2
.dbline 132
rjmp L44
L55:
.dbline 135
.dbline 135
clr R2
clr R3
sts _OutLedDely+1,R3
sts _OutLedDely,R2
.dbline 135
in R24,0x15
ori R24,12
out 0x15,R24
.dbline 135
L45:
.dbline -2
L44:
.dbline 0 ; func end
ret
.dbend
.dbfunc e OutTone _OutTone fV
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -