📄 time_8515.s
字号:
; for(i=0;i<8;i++)
clr R22
rjmp L33
L30:
.dbline 153
; {
.dbline 154
; if((PINA & 0x10)==0) //操作的是PA4
sbic 0x19,4
rjmp L34
.dbline 155
; {
.dbline 156
; mid &= ~(1<<i); //读取0
ldi R16,1
mov R17,R22
rcall lsl8
mov R2,R16
com R2
and R20,R2
.dbline 157
; }
rjmp L35
L34:
.dbline 159
; else
; {
.dbline 160
; mid |= (1<<i); //读取1
ldi R16,1
mov R17,R22
rcall lsl8
or R20,R16
.dbline 161
; }
L35:
.dbline 162
sbi 0x1b,3
.dbline 163
cbi 0x1b,3
.dbline 164
L31:
.dbline 152
inc R22
L33:
.dbline 152
cpi R22,8
brlo L30
.dbline 165
; PORTA |= (1<<PA3); //时钟置高
; PORTA &= ~(1<<PA3); //时钟置低,产生下降沿
; }
; return (mid);
mov R16,R20
.dbline -2
L29:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r mid 20 c
.dbsym r i 22 c
.dbend
.dbfunc e write_DS1302 _write_DS1302 fV
; i -> R20
.even
_write_DS1302::
rcall push_gset1
.dbline -1
.dbline 176
; }
; /************************************************
; 函 数 名: write_DS1302
; 功 能: 给DS1302写入上电数据,置需要设定的时钟值
; 输入参数: /
; 输出参数: /
; 描 述: 单字节和多字节操作模式都用了。
; 数据格式为:秒 分 时 日 月 星期 年 写保护字节
; ***********************************************/
; void write_DS1302 (void)
; {
.dbline 179
; uchar i;
;
; DDRA |= (1<<DDA5)|(1<<DDA4)|(1<<DDA3); //复位,数据和时钟脚都为输出
in R24,0x1a
ori R24,56
out 0x1a,R24
.dbline 180
; PORTA &= ~(1<<PA5); //RST=0
cbi 0x1b,5
.dbline 181
; PORTA &= ~(1<<PA3); //CLK=0
cbi 0x1b,3
.dbline 182
; PORTA |= (1<<PA5); //RST=1
sbi 0x1b,5
.dbline 183
; NOP();
nop
.dbline 184
; InputByte(0x8e); //写保护命令字节的地址
ldi R16,142
rcall _InputByte
.dbline 185
; InputByte(0x00); //解除写保护命令
clr R16
rcall _InputByte
.dbline 186
; PORTA &= ~(1<<PA5); //RST=0
cbi 0x1b,5
.dbline 187
; PORTA &= ~(1<<PA3); //CLK=0
cbi 0x1b,3
.dbline 188
; PORTA |= (1<<PA5); //RST=1
sbi 0x1b,5
.dbline 189
; NOP();
nop
.dbline 190
; InputByte(0b10010000); //涓流充电寄存器的地址
ldi R16,144
rcall _InputByte
.dbline 191
; InputByte(0b10101010); //设置涓流充电
ldi R16,170
rcall _InputByte
.dbline 192
; PORTA &= ~(1<<PA5); //RST=0
cbi 0x1b,5
.dbline 193
; PORTA &= ~(1<<PA3); //CLK=0
cbi 0x1b,3
.dbline 194
; PORTA |= (1<<PA5); //RST=1
sbi 0x1b,5
.dbline 195
; NOP();
nop
.dbline 196
; InputByte(0xbe); //多字节写操作命令
ldi R16,190
rcall _InputByte
.dbline 197
; for (i=0;i<8;i++)
clr R20
rjmp L40
L37:
.dbline 198
.dbline 199
ldi R24,<_buf_write
ldi R25,>_buf_write
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R16,z+0
rcall _InputByte
.dbline 200
L38:
.dbline 197
inc R20
L40:
.dbline 197
cpi R20,8
brlo L37
.dbline 201
; {
; InputByte(buf_write[i]);
; }
; PORTA &= ~(1<<PA5); //RST=0
cbi 0x1b,5
.dbline -2
L36:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e read_DS1302 _read_DS1302 fV
; i -> R20
.even
_read_DS1302::
rcall push_gset1
.dbline -1
.dbline 212
; }
; /************************************************
; 函 数 名: read_DS1302
; 功 能: 读取DS1302的所有时间数据
; 输入参数: /
; 输出参数: /
; 描 述: 使用多字节方式。
; 数据格式为:秒 分 时 日 月 星期 年
; ***********************************************/
; void read_DS1302 (void)
; {
.dbline 214
; uchar i;
; DDRA |= (1<<DDA5)|(1<<DDA3); //复位和时钟脚都为输出
in R24,0x1a
ori R24,40
out 0x1a,R24
.dbline 215
; PORTA &= ~(1<<PA5); //RST=0
cbi 0x1b,5
.dbline 216
; PORTA &= ~(1<<PA3); //CLK=0
cbi 0x1b,3
.dbline 217
; PORTA |= (1<<PA5); //RST=1
sbi 0x1b,5
.dbline 218
; DDRA |= (1<<DDA4); //数据脚为输出
sbi 0x1a,4
.dbline 219
; NOP();
nop
.dbline 220
; InputByte(0xbf); //多字节读命令
ldi R16,191
rcall _InputByte
.dbline 221
; DDRA &= ~(1<<DDA4); //数据脚改为输入
cbi 0x1a,4
.dbline 222
; NOP();
nop
.dbline 223
; for (i=0;i<8;i++)
clr R20
rjmp L45
L42:
.dbline 224
.dbline 225
rcall _OutputByte
ldi R24,<_buf_read
ldi R25,>_buf_read
mov R30,R20
clr R31
add R30,R24
adc R31,R25
std z+0,R16
.dbline 226
L43:
.dbline 223
inc R20
L45:
.dbline 223
cpi R20,8
brlo L42
.dbline 227
; {
; buf_read[i]=OutputByte();
; }
; PORTA &= ~(1<<PA5); //RST=0
cbi 0x1b,5
.dbline -2
L41:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e write_pc232 _write_pc232 fV
; i -> R20
.even
_write_pc232::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 238
; }
;
; /********************************************************
; 子程序名: write_pc232()
; 功 能: 串口发送一个字节
; 输入参数: /
; 输出参数: /
; 描 述: 把数据发送出去先发送再检测,发完后,才离开
; ********************************************************/
; void write_pc232(uchar i)
; {
L47:
.dbline 239
L48:
.dbline 239
; while(!(UCSRA&(1<<UDRE))); //1字节发送完毕?
sbis 0xb,5
rjmp L47
.dbline 240
; UDR = i; //发送一个字符数据
out 0xc,R20
.dbline 241
; DelaymS (10);
ldi R16,10
ldi R17,0
rcall _DelaymS
.dbline -2
L46:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e mcu_Init _mcu_Init fV
.even
_mcu_Init::
.dbline -1
.dbline 251
; }
; /************************************************
; 函 数 名: mcu_Init()
; 功 能: 单片机初始化函数
; 输入参数: /
; 输出参数: /
; 描 述: 相关口方向的设置等
; ***********************************************/
; void mcu_Init(void)
; {
.dbline 252
; DDRC = 0xff; //PC口为推挽1输出,段码
ldi R24,255
out 0x14,R24
.dbline 253
; DDRD = 0xff; //PD口为推挽1输出,位码,PD7为485DE脚。
out 0x11,R24
.dbline 254
; DDRA = 0xff; //PA口接DS1302
out 0x1a,R24
.dbline -2
L50:
.dbline 0 ; func end
ret
.dbend
.dbfunc e usart_Init _usart_Init fV
.even
_usart_Init::
.dbline -1
.dbline 264
; }
; /********************************************************
; 子程序名: usart_Init()
; 功 能: 串口初始化
; 输入参数: /
; 输出参数: /
; 描 述: /
; ********************************************************/
; void usart_Init (void)
; {
.dbline 265
; UBRRL=51; //波特率寄存器,UART:9600bps,8.000MHz
ldi R24,51
out 0x9,R24
.dbline 266
; UCSRB = (1<<RXEN)|(1<<TXEN); //UART控制寄存器,RXD&TXD使能
ldi R24,24
out 0xa,R24
.dbline -2
L51:
.dbline 0 ; func end
ret
.dbend
.dbfunc e spk _spk fV
; i -> R20
.even
_spk::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 276
; }
; /************************************************
; 函 数 名: spk()
; 功 能: 蜂鸣器鸣叫一声函数
; 输入参数:
; 输出参数:
; 描 述: /
; ***********************************************/
; void spk (uchar i)
; {
.dbline 277
; DDRA |= (1<<2); //DDRA2为输出。
sbi 0x1a,2
.dbline 278
; PORTA &= ~(1<<PA2); //蜂鸣器响
cbi 0x1b,2
.dbline 279
; DelaymS (i); //延迟
mov R16,R20
clr R17
rcall _DelaymS
.dbline 280
; PORTA |= (1<<PA2); //蜂鸣器关闭
sbi 0x1b,2
.dbline -2
L52:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e data_conversion _data_conversion fV
.even
_data_conversion::
.dbline -1
.dbline 291
; }
; /********************************************************
; 子程序名: data_conversion()
; 输入参数: 数据转换程序
; 输出参数: /
; 描 述: /1302读出的数据是BCD码形式,必须进行数制转换。
; 数据格式: 秒 分 时 日 月 星期 年 写保护字节
; 显示格式: 秒秒 分分 时时 日日 月月 年年 辅助
; ********************************************************/
; void data_conversion (void)
; {
.dbline 292
; buf_time[29] = (buf_read[0] & 0x0f) + '0'; //秒的低位
lds R24,_buf_read
andi R24,15
subi R24,208 ; addi 48
sts _buf_time+29,R24
.dbline 293
; buf_time[28] = (buf_read[0] >> 4 ) + '0'; //秒的高位
lds R24,_buf_read
swap R24
andi R24,#0x0F
subi R24,208 ; addi 48
sts _buf_time+28,R24
.dbline 295
;
; buf_time[26] = (buf_read[1] & 0x0f) + '0'; //分的低位
lds R24,_buf_read+1
andi R24,15
subi R24,208 ; addi 48
sts _buf_time+26,R24
.dbline 296
; buf_time[25] = (buf_read[1] >> 4 ) + '0'; //分的高位
lds R24,_buf_read+1
swap R24
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -