📄 rtc8025.s
字号:
.dbline 152
in R24,0x12
andi R24,254
out 0x12,R24
.dbline 153
ldi R16,1
ldi R17,0
xcall _RTC_Delay
.dbline 154
L22:
.dbline 143
mov R2,R20
clr R3
subi R20,1
tst R2
brne L21
.dbline 155
; RTCSCL_L;
; RTC_Delay(1);
; }
; return Byte;
mov R16,R22
.dbline -2
L20:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r Byte 22 c
.dbend
.dbfunc e Write_Byte _Write_Byte fc
; i -> R20
; Data -> R22
.even
_Write_Byte::
xcall push_gset2
mov R22,R16
.dbline -1
.dbline 165
; }
; //==========================================================
; //函 数: void Write_Byte(unsigned char Data)
; //功 能: R8025写一个Byte
; //入口参数: 写的数据
; //出口参数: 返回1错误,0成功
; //日 期: 2005-07-20 覃道堂
; //==========================================================
; unsigned char Write_Byte(unsigned char Data)
; {
.dbline 166
; unsigned char i = 8;
ldi R20,8
.dbline 168
;
; RTCSDA_INPUT;
in R24,0x11
andi R24,253
out 0x11,R24
.dbline 169
; RTC_Delay(1);
ldi R16,1
ldi R17,0
xcall _RTC_Delay
.dbline 170
; if((PIND & 0x02) == 0)
sbic 0x10,1
rjmp L27
.dbline 171
; return 1;
ldi R16,1
xjmp L26
L27:
.dbline 172
; RTCSDA_L;
in R24,0x12
andi R24,253
out 0x12,R24
.dbline 173
; RTCSDA_OUTPUT;
sbi 0x11,1
xjmp L30
L29:
.dbline 175
; while(i --)
; {
.dbline 176
; if(Data & 0x80)
sbrs R22,7
rjmp L32
.dbline 177
; RTCSDA_H;
sbi 0x12,1
xjmp L33
L32:
.dbline 179
; else
; RTCSDA_L;
in R24,0x12
andi R24,253
out 0x12,R24
L33:
.dbline 180
sbi 0x12,0
.dbline 181
ldi R16,1
ldi R17,0
xcall _RTC_Delay
.dbline 182
in R24,0x12
andi R24,254
out 0x12,R24
.dbline 183
ldi R16,1
ldi R17,0
xcall _RTC_Delay
.dbline 184
lsl R22
.dbline 185
L30:
.dbline 174
mov R2,R20
clr R3
subi R20,1
tst R2
brne L29
.dbline 186
; RTCSCL_H;
; RTC_Delay(1);
; RTCSCL_L;
; RTC_Delay(1);
; Data = Data << 1;
; }
; return 0;
clr R16
.dbline -2
L26:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r Data 22 c
.dbend
.dbfunc e Read_Time_Data _Read_Time_Data fc
; i -> R20
; Len -> R22
; Address -> R20
; Frame -> R10,R11
.even
_Read_Time_Data::
xcall push_gset3
mov R20,R18
movw R10,R16
ldd R22,y+6
.dbline -1
.dbline 200
; }
;
; //==========================================================
; //函 数: unsigned char Read_Time_Data(unsigned char *Frame,
; // unsigned char Address,unsigned char Len)
; //功 能: 读时间数据
; //入口参数: 存放的地方,读的地址,长度
; //出口参数: 返回1错误,0成功
; //日 期: 2005-07-20 覃道堂
; //==========================================================
; unsigned char Read_Time_Data(unsigned char *Frame,
; unsigned char Address,
; unsigned char Len)
; {
.dbline 203
; unsigned char i;
;
; Send_Start();
xcall _Send_Start
.dbline 204
; Write_Byte(0x64); //写数据命令;
ldi R16,100
xcall _Write_Byte
.dbline 205
; if(Receive_ACK())
xcall _Receive_ACK
tst R16
breq L35
.dbline 206
; return 1;
ldi R16,1
xjmp L34
L35:
.dbline 207
; Write_Byte(Address); //写入要读的首地址
mov R16,R20
xcall _Write_Byte
.dbline 208
; if(Receive_ACK())
xcall _Receive_ACK
tst R16
breq L37
.dbline 209
; return 1;
ldi R16,1
xjmp L34
L37:
.dbline 210
; Send_Start();
xcall _Send_Start
.dbline 211
; Write_Byte(0x65); //读数据命令
ldi R16,101
xcall _Write_Byte
.dbline 212
; if(Receive_ACK())
xcall _Receive_ACK
tst R16
breq L39
.dbline 213
; return 1;
ldi R16,1
xjmp L34
L39:
.dbline 214
; for(i = 0;i < Len;i ++)
clr R20
xjmp L44
L41:
.dbline 215
; {
.dbline 216
; Frame[i] = Read_Byte();
xcall _Read_Byte
mov R30,R20
clr R31
add R30,R10
adc R31,R11
std z+0,R16
.dbline 217
; if(i == (Len - 1))
mov R24,R22
subi R24,1
cp R20,R24
brne L45
.dbline 218
; Send_No_ACK();
xcall _Send_No_ACK
xjmp L46
L45:
.dbline 220
; else
; Send_ACK();
xcall _Send_ACK
L46:
.dbline 221
L42:
.dbline 214
inc R20
L44:
.dbline 214
cp R20,R22
brlo L41
.dbline 222
; }
; Send_Stop();
xcall _Send_Stop
.dbline 223
; return 0;
clr R16
.dbline -2
L34:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r Len 22 c
.dbsym r Address 20 c
.dbsym r Frame 10 pc
.dbend
.dbfunc e Write_Time_Data _Write_Time_Data fc
; i -> R20
; Len -> R22
; Address -> R20
; Frame -> R10,R11
.even
_Write_Time_Data::
xcall push_gset3
mov R20,R18
movw R10,R16
ldd R22,y+6
.dbline -1
.dbline 237
; }
; //==========================================================
; //函 数: unsigned char Write_Time_Data(unsigned char *Frame,
; // unsigned char Address,
; // unsigned char Len)
; //功 能: 写时间和数据
; //入口参数: 写入数据,地址,长度
; //出口参数: 返回1错误,0成功
; //日 期: 2005-07-20 覃道堂
; //==========================================================
; unsigned char Write_Time_Data(unsigned char *Frame,
; unsigned char Address,
; unsigned char Len)
; {
.dbline 240
; unsigned char i;
;
; Send_Start();
xcall _Send_Start
.dbline 241
; Write_Byte(0x64); //写数据命令;
ldi R16,100
xcall _Write_Byte
.dbline 242
; if(Receive_ACK())
xcall _Receive_ACK
tst R16
breq L48
.dbline 243
; return 1;
ldi R16,1
xjmp L47
L48:
.dbline 244
; Write_Byte(Address); //写入要读的首地址
mov R16,R20
xcall _Write_Byte
.dbline 245
; if(Receive_ACK())
xcall _Receive_ACK
tst R16
breq L50
.dbline 246
; return 1;
ldi R16,1
xjmp L47
L50:
.dbline 247
; for(i = 0;i < Len;i ++)
clr R20
xjmp L55
L52:
.dbline 248
; {
.dbline 249
; Write_Byte(Frame[i]);
mov R30,R20
clr R31
add R30,R10
adc R31,R11
ldd R16,z+0
xcall _Write_Byte
.dbline 250
; if(Receive_ACK())
xcall _Receive_ACK
tst R16
breq L56
.dbline 251
; return 1;
ldi R16,1
xjmp L47
L56:
.dbline 252
L53:
.dbline 247
inc R20
L55:
.dbline 247
cp R20,R22
brlo L52
.dbline 253
; }
; Send_Stop();
xcall _Send_Stop
.dbline 254
; return 0;
clr R16
.dbline -2
L47:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r Len 22 c
.dbsym r Address 20 c
.dbsym r Frame 10 pc
.dbend
.dbfunc e Reset_R8025 _Reset_R8025 fV
; Read_COL -> y+1
; i -> R20,R21
.even
_Reset_R8025::
xcall push_gset1
sbiw R28,3
.dbline -1
.dbline 264
; }
; //==========================================================
; //函 数: void Reset_R8025(void)
; //功 能: 复位
; //入口参数: 无
; //出口参数: 无
; //日 期: 2005-07-20 覃道堂
; //==========================================================
; void Reset_R8025(void)
; {
.dbline 268
; unsigned int i;
; unsigned char Read_COL[2];
;
; Read_COL[0] = 0x60;
ldi R24,96
std y+1,R24
.dbline 269
; Read_COL[1] = 0x20;
ldi R24,32
std y+2,R24
.dbline 270
; for(i = 0;i < 3;i ++)
clr R20
clr R21
xjmp L63
L60:
.dbline 271
; {
.dbline 272
; if(Write_Time_Data(Read_COL,Control_Address,2) == 0)
ldi R24,2
std y+0,R24
ldi R18,224
movw R16,R28
subi R16,255 ; offset = 1
sbci R17,255
xcall _Write_Time_Data
tst R16
brne L64
.dbline 273
; break;
xjmp L62
L64:
.dbline 274
L61:
.dbline 270
subi R20,255 ; offset = 1
sbci R21,255
L63:
.dbline 270
cpi R20,3
ldi R30,0
cpc R21,R30
brlo L60
L62:
.dbline 275
; }
; for(i = 0;i < 30000;i ++)
clr R20
clr R21
xjmp L69
L66:
.dbline 276
nop
L67:
.dbline 275
subi R20,255 ; offset = 1
sbci R21,255
L69:
.dbline 275
cpi R20,48
ldi R30,117
cpc R21,R30
brlo L66
.dbline -2
L58:
adiw R28,3
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym l Read_COL 1 A[2:2]c
.dbsym r i 20 i
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -