⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssle4442.s

📁 基于AVR单片机实现了食堂IC卡售饭机系统
💻 S
📖 第 1 页 / 共 4 页
字号:
	.module SSLE4442.c
	.area data(ram, con, rel)
_table::
	.blkb 2
	.area idata
	.byte 63,6
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 91,'O
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 'f,'m
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 125,7
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 127,'o
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 'y,'q
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 's,0
	.area data(ram, con, rel)
	.dbfile E:\张军\AVR\光盘内容\实例源文件\第六章程序\SSLE4442.c
	.dbsym e table _table A[14:14]c
_EEEEE::
	.blkb 2
	.area idata
	.byte 'y,'y
	.area data(ram, con, rel)
	.dbfile E:\张军\AVR\光盘内容\实例源文件\第六章程序\SSLE4442.c
	.blkb 2
	.area idata
	.byte 'y,'y
	.area data(ram, con, rel)
	.dbfile E:\张军\AVR\光盘内容\实例源文件\第六章程序\SSLE4442.c
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张军\AVR\光盘内容\实例源文件\第六章程序\SSLE4442.c
	.dbsym e EEEEE _EEEEE A[5:5]c
_FFFFF::
	.blkb 2
	.area idata
	.byte 'q,'q
	.area data(ram, con, rel)
	.dbfile E:\张军\AVR\光盘内容\实例源文件\第六章程序\SSLE4442.c
	.blkb 2
	.area idata
	.byte 'q,'q
	.area data(ram, con, rel)
	.dbfile E:\张军\AVR\光盘内容\实例源文件\第六章程序\SSLE4442.c
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张军\AVR\光盘内容\实例源文件\第六章程序\SSLE4442.c
	.dbsym e FFFFF _FFFFF A[5:5]c
	.area text(rom, con, rel)
	.dbfile E:\张军\AVR\光盘内容\实例源文件\第六章程序\SSLE4442.c
	.dbfunc e Voice _Voice fV
;             PD -> R16
	.even
_Voice::
	.dbline -1
	.dbline 32
; //*********************FileName:Main.c*********************//
; //*********************Author:Steaven2000@163.com**********//
; //********************Version:1.2*************************//
; //******************LastUpdate:2004-11-03*****************//
; 
; #include <io8535v.h>
; #include <macros.h>
; #define uchar unsigned char
; #define uint unsigned int
; 
; //**********定义全局变量*******************//
; //查表0    1    2    3    4    5   6    7    8    9    E    F   P   OFF
; uchar table[14]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x79,0x71,0x73,0x00};
; uchar ICcode[4];//定义IC卡复位时读出的4字节代码;
; uchar ICcontent[14];//定义IC卡有效信息;
; uchar Money[5];//定义IC卡内金额;
; uchar EEEEE[5]={0x79,0x79,0x79,0x79};
; uchar FFFFF[5]={0x71,0x71,0x71,0x71};
; uchar IC_Flag;//定义IC卡上电标志;
; uchar Num_Flag;//数标志;
; uchar Add_Flag;//加标志
; uchar Sub_Flag;//减标志
; uchar Init_Flag;//初始化标志
; uchar Repair_Flag;//修卡标志;
; uchar Enter_Flag;//确认标志
; uchar Point_Flag;//.标志
; uchar Key_Flag; //按键标志;
; 
;      
; //***********IC卡引脚信号处理***************//
; void Voice(uchar PD) //Voice=PD^7
; {if(PD==1) PORTD|=0x80;//Voice置1
	.dbline 32
	cpi R16,1
	brne L2
	.dbline 32
	sbi 0x12,7
	rjmp L3
L2:
	.dbline 33
	in R24,0x12
	andi R24,175
	out 0x12,R24
L3:
	.dbline -2
	.dbline 34
;  else      PORTD&=~80; //Voice置0
; }
L1:
	.dbline 0 ; func end
	ret
	.dbsym r PD 16 c
	.dbend
	.dbfunc e RST _RST fV
;             PD -> R16
	.even
_RST::
	.dbline -1
	.dbline 37
; 
; void RST(uchar PD)  //RST=PD^6
; {if(PD==1) PORTD|=0x40;//RST置1
	.dbline 37
	cpi R16,1
	brne L5
	.dbline 37
	sbi 0x12,6
	rjmp L6
L5:
	.dbline 38
	cbi 0x12,6
L6:
	.dbline -2
	.dbline 39
;  else       PORTD&=~0x40;//RST置0
; }
L4:
	.dbline 0 ; func end
	ret
	.dbsym r PD 16 c
	.dbend
	.dbfunc e CLK _CLK fV
;             PD -> R16
	.even
_CLK::
	.dbline -1
	.dbline 42
; 
; void CLK(uchar PD) //CLK=PD^5
; {if(PD==1) PORTD|=0x20;//CLK置1
	.dbline 42
	cpi R16,1
	brne L8
	.dbline 42
	sbi 0x12,5
	rjmp L9
L8:
	.dbline 43
	cbi 0x12,5
L9:
	.dbline -2
	.dbline 44
;  else       PORTD&=~0x20;//CLK置0
; }
L7:
	.dbline 0 ; func end
	ret
	.dbsym r PD 16 c
	.dbend
	.dbfunc e IO _IO fV
;             PD -> R16
	.even
_IO::
	.dbline -1
	.dbline 47
; 
; void IO(uchar PD)  //IO=PD^4
; {if(PD==1) PORTD|=0x10;//IO置1
	.dbline 47
	cpi R16,1
	brne L11
	.dbline 47
	sbi 0x12,4
	rjmp L12
L11:
	.dbline 48
	cbi 0x12,4
L12:
	.dbline -2
	.dbline 49
;  else       PORTD&=~0x10;//IO置0
; }
L10:
	.dbline 0 ; func end
	ret
	.dbsym r PD 16 c
	.dbend
	.dbfunc e SetIO _SetIO fV
;              i -> R16
	.even
_SetIO::
	.dbline -1
	.dbline 52
;  
; void SetIO(uchar i)//设置IO口属性
; {if(i==1) DDRD=0xf0; //IO口输出:1111 0000
	.dbline 52
	cpi R16,1
	brne L14
	.dbline 52
	ldi R24,240
	out 0x11,R24
	rjmp L15
L14:
	.dbline 53
;  else     DDRD=0xe0; //IO口输如:1110 0000
	ldi R24,224
	out 0x11,R24
L15:
	.dbline 54
;  PORTD=0x00;//不带上拉电阻;
	clr R2
	out 0x12,R2
	.dbline -2
	.dbline 55
; }
L13:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 c
	.dbend
	.dbfunc e DelayUs _DelayUs fV
;              i -> R16
	.even
_DelayUs::
	.dbline -1
	.dbline 60
; 
; //**********延时函数(Us数量级)*********//
; //单周期指令执行时间,执行时间1/8us*分频系数(取8分频则刚好1us);
; void DelayUs(uchar i)
; {for(;i!=0;i--)  
	.dbline 60
	rjmp L20
L17:
	.dbline 61
	nop
L18:
	.dbline 60
	dec R16
L20:
	.dbline 60
	tst R16
	brne L17
	.dbline -2
	.dbline 62
;  NOP();
; }
L16:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 c
	.dbend
	.dbfunc e DelayMs _DelayMs fV
;              k -> R20
;              j -> R22
;              i -> R16,R17
	.even
_DelayMs::
	rcall push_gset2
	.dbline -1
	.dbline 66
; 
; //****************延时函数(Ms数量级)*********//
; void DelayMs(uint i)
; {uchar j,k;
	.dbline 67
;  for(;i!=0;i--)
	rjmp L25
L22:
	.dbline 68
;     {for(k=0;k<4;k++)
	.dbline 68
	clr R20
	rjmp L29
L26:
	.dbline 69
	.dbline 69
	ldi R22,250
	rjmp L33
L30:
	.dbline 69
	nop
L31:
	.dbline 69
	dec R22
L33:
	.dbline 69
	tst R22
	brne L30
	.dbline 69
L27:
	.dbline 68
	inc R20
L29:
	.dbline 68
	cpi R20,4
	brlo L26
	.dbline 70
L23:
	.dbline 67
	subi R16,1
	sbci R17,0
L25:
	.dbline 67
	cpi R16,0
	cpc R16,R17
	brne L22
X0:
	.dbline -2
	.dbline 71
;       {for(j=250;j!=0;j--) NOP();}
; 	}
; }
L21:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r k 20 c
	.dbsym r j 22 c
	.dbsym r i 16 i
	.dbend
	.dbfunc e ReceiveData _ReceiveData fc
;       io_value -> R20
;          count -> R22
;          value -> R10
	.even
_ReceiveData::
	rcall push_gset3
	.dbline -1
	.dbline 75
; 
; //****************接收数据**************//
; uchar ReceiveData(void)
; {uchar count;
	.dbline 78
;  uchar value;
;  uchar io_value;
;  value=0;
	clr R10
	.dbline 79
;  SetIO(0);//设置IO脚为输入;
	clr R16
	rcall _SetIO
	.dbline 80
;  CLK(0);
	clr R16
	rcall _CLK
	.dbline 82
;  //IO=1;
;  for(count=0;count<8;count++)
	clr R22
	rjmp L38
L35:
	.dbline 83
;   {value=value>>1; 
	.dbline 83
	lsr R10
	.dbline 84
;    CLK(1);
	ldi R16,1
	rcall _CLK
	.dbline 85
;    DelayUs(2);
	ldi R16,2
	rcall _DelayUs
	.dbline 86
;    io_value=PIND;
	in R20,0x10
	.dbline 87
;    CLK(0);
	clr R16
	rcall _CLK
	.dbline 88
;    DelayUs(2);
	ldi R16,2
	rcall _DelayUs
	.dbline 89
;    if(io_value&0x10==0x10) value|=0x80;//判断IO脚是否为1
	sbrs R20,0
	rjmp L39
	.dbline 89
	mov R24,R10
	ori R24,128
	mov R10,R24
	rjmp L40
L39:
	.dbline 90
;    else value&=0x7f;
	mov R24,R10
	andi R24,127
	mov R10,R24
L40:
	.dbline 91
L36:
	.dbline 82
	inc R22
L38:
	.dbline 82
	cpi R22,8
	brlo L35
	.dbline 92
;   }
;  return (value);
	mov R16,R10
	.dbline -2
L34:
	rcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r io_value 20 c
	.dbsym r count 22 c
	.dbsym r value 10 c
	.dbend
	.dbfunc e SendData _SendData fV
;          value -> R20
;          count -> R20
;          Xdata -> R22
	.even
_SendData::
	rcall push_gset2
	mov R22,R16
	.dbline -1
	.dbline 97
; }
; 
; //********************发送数据************//
; void SendData(uchar Xdata)  
; {uchar count;
	.dbline 99
;  uchar value;
;  SetIO(1);////设置IO脚为输出;
	ldi R16,1
	rcall _SetIO
	.dbline 100
;  value=Xdata;
	.dbline 101
;  for(count=8;count!=0;count--)
	ldi R20,8
	rjmp L45
L42:
	.dbline 102
;  	{CLK(0);
	.dbline 102
	clr R16
	rcall _CLK
	.dbline 103
; 	 if((Xdata<<(count-1))&0x80) IO(1);
	mov R17,R20
	subi R17,1
	mov R16,R22
	rcall lsl8
	mov R24,R16
	andi R24,128
	breq L46
	.dbline 103
	ldi R16,1
	rcall _IO
	rjmp L47
L46:
	.dbline 104
; 	 else IO(0);
	clr R16
	rcall _IO
L47:
	.dbline 105
	ldi R16,1
	rcall _CLK
	.dbline 106
	ldi R16,2
	rcall _DelayUs
	.dbline 107
	clr R16
	rcall _CLK
	.dbline 107
L43:
	.dbline 101
	dec R20
L45:
	.dbline 101
	tst R20
	brne L42
	.dbline -2
	.dbline 108
; 	 CLK(1);
; 	 DelayUs(2);
; 	 CLK(0);}
; }
L41:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r value 20 c
	.dbsym r count 20 c
	.dbsym r Xdata 22 c
	.dbend
	.dbfunc e ResetIC _ResetIC fV
;          count -> R20
;          Xdata -> R22,R23
	.even
_ResetIC::
	rcall push_gset2
	mov R22,R16
	mov R23,R17
	.dbline -1
	.dbline 112
; 
; //****************IC卡复位************************//
; void ResetIC(uchar *Xdata)
; {uchar count;
	.dbline 113
;  SetIO(1); //设置IC卡引脚的属性
	ldi R16,1
	rcall _SetIO
	.dbline 114
;  RST(0);
	clr R16
	rcall _RST
	.dbline 115
;  CLK(0);
	clr R16
	rcall _CLK
	.dbline 116
;  IO(1);
	ldi R16,1
	rcall _IO
	.dbline 117
;  DelayUs(5);
	ldi R16,5
	rcall _DelayUs
	.dbline 118
;  RST(1);
	ldi R16,1
	rcall _RST
	.dbline 119
;  DelayUs(5);
	ldi R16,5
	rcall _DelayUs
	.dbline 120
;  CLK(1);
	ldi R16,1
	rcall _CLK
	.dbline 121
;  DelayUs(5);
	ldi R16,5
	rcall _DelayUs
	.dbline 122
;  CLK(0);
	clr R16
	rcall _CLK
	.dbline 123
;  DelayUs(5);
	ldi R16,5
	rcall _DelayUs
	.dbline 124
;  RST(0);
	clr R16
	rcall _RST
	.dbline 125
;  for(count=4;count!=0;count--)
	ldi R20,4
	rjmp L52
L49:
	.dbline 126
	.dbline 126
	rcall _ReceiveData
	mov R30,R22
	mov R31,R23
	std z+0,R16
	.dbline 127
	subi R22,254  ; offset = 2
	sbci R23,255
	.dbline 127
L50:
	.dbline 125
	dec R20
L52:
	.dbline 125
	tst R20
	brne L49
	.dbline -2
	.dbline 128
;  	{*Xdata=ReceiveData();
; 	 Xdata+=2;}
; } 
L48:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r count 20 c
	.dbsym r Xdata 22 pc
	.dbend
	.dbfunc e Start _Start fV
	.even
_Start::
	.dbline -1
	.dbline 132
; 
; //*******************Start条件****************//
; void Start(void)
; {SetIO(1);
	.dbline 132
	ldi R16,1
	rcall _SetIO
	.dbline 133
;  CLK(0);
	clr R16
	rcall _CLK
	.dbline 134
;  IO(0);
	clr R16
	rcall _IO
	.dbline 135
;  DelayUs(2);
	ldi R16,2
	rcall _DelayUs
	.dbline 136
;  CLK(1);
	ldi R16,1
	rcall _CLK
	.dbline 137
;  IO(1);
	ldi R16,1
	rcall _IO
	.dbline 138
;  DelayUs(2);
	ldi R16,2
	rcall _DelayUs
	.dbline 139
;  IO(0);
	clr R16
	rcall _IO
	.dbline 140
;  CLK(0);
	clr R16
	.dbline -2
	.dbline 141
; }
L53:
	.dbline 0 ; func end
	rjmp _CLK
	.dbend
	.dbfunc e Stop _Stop fV
	.even
_Stop::
	.dbline -1
	.dbline 145
; 
; //*******************Stop条件****************//
; void Stop(void)
; {CLK(0);
	.dbline 145
	clr R16
	rcall _CLK
	.dbline 146
;  IO(0);
	clr R16
	rcall _IO
	.dbline 147
;  DelayUs(2);
	ldi R16,2
	rcall _DelayUs
	.dbline 148
;  CLK(1);
	ldi R16,1
	rcall _CLK
	.dbline 149
;  IO(0);
	clr R16
	rcall _IO
	.dbline 150
;  DelayUs(2);
	ldi R16,2
	rcall _DelayUs
	.dbline 151
;  IO(1);
	ldi R16,1
	rcall _IO
	.dbline 152
;  DelayUs(2);
	ldi R16,2
	rcall _DelayUs
	.dbline 153
;  IO(0);
	clr R16
	.dbline -2
	.dbline 154
; }
L54:
	.dbline 0 ; func end
	rjmp _IO
	.dbend
	.dbfunc e Process _Process fV
;              j -> R20,R21
	.even
_Process::
	rcall push_gset1
	.dbline -1
	.dbline 158
; 
; //******************处理过程**************//
; void Process(void)
; {uint j;
	.dbline 159
;  SetIO(1);//设置IO脚为输出脚
	ldi R16,1
	rcall _SetIO
	.dbline 160
;  CLK(0);
	clr R16
	rcall _CLK
	.dbline 161
;  DelayUs(5);
	ldi R16,5
	rcall _DelayUs
	.dbline 162
;  IO(0);
	clr R16
	rcall _IO
	.dbline 163
;  for(j=255;j>0;j--)
	ldi R20,255
	ldi R21,0
	rjmp L59
L56:
	.dbline 164
	.dbline 164
	ldi R16,1
	rcall _CLK
	.dbline 165
	ldi R16,5
	rcall _DelayUs
	.dbline 166
	clr R16
	rcall _CLK
	.dbline 167
	ldi R16,5
	rcall _DelayUs
	.dbline 168
L57:
	.dbline 163
	subi R20,1
	sbci R21,0
L59:
	.dbline 163
	cpi R20,0
	cpc R20,R21
	brne L56
X1:
	.dbline 169
;  	{CLK(1);
; 	 DelayUs(5);
; 	 CLK(0);
; 	 DelayUs(5);
; 	}
;  IO(1);
	ldi R16,1
	rcall _IO
	.dbline -2
	.dbline 170
; }
L55:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r j 20 i
	.dbend
	.dbfunc e Command _Command fV
;          Byte3 -> y+4
;          Byte2 -> R20
;          Byte1 -> R22
	.even
_Command::
	rcall push_gset2
	mov R20,R18
	mov R22,R16
	.dbline -1
	.dbline 177
; 
; //****************说明*********************//
; //*********输出模式接口命令,包括读主存储器30H,读保护存储器34H,读安全代码的接口命令31H***********//
; //******处理模式数据接口命令,包括写主存储器38H,写保护存储器3CH,写安全代码39H,校验安全代码33H*******//
; 
; void Command(uchar Byte1,uchar Byte2,uchar Byte3)
; {Start();
	.dbline 177
	rcall _Start
	.dbline 178
;  SendData(Byte1);
	mov R16,R22
	rcall _SendData
	.dbline 179
;  SendData(Byte2);
	mov R16,R20
	rcall _SendData
	.dbline 180
;  SendData(Byte3);
	ldd R16,y+4
	rcall _SendData
	.dbline 181
;  Stop();
	rcall _Stop
	.dbline -2
	.dbline 182
; }
L60:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l Byte3 4 c

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -