|
read_DS_data:
rcall open_DS_to_read_write
ldi temporary1,(1**twsta)+(1**twen)+(1**twint)
rcall wait_twint_oneldi temporary1,0b11010001 ;SLA + R
out twdr,temporary1 ;select DS
ldi temporary1,(1**twint)+(1**twen) ;SLA+R send startrcall wait_twint_one
ldi temporary1,(1**twint)+(1**twen) ;not ack send
rcall wait_twint_one
in temporary1,twdr
exit_with_stop_cond:
rcall send_stop_condition
retwait_twint_one:
out twcr,temporary1wait_twint_one__:
in temporary1,twcr
sbrs temporary1,twint
rjmp wait_twint_one__
ret
write_DS_data:
push temporary1
rcall open_DS_to_read_writepop temporary1
out twdr,temporary1
ldi temporary1,(1**twint)+(1**twen)
rcall wait_twint_one
rjmp exit_with_stop_cond
send_stop_condition:
push temporary1
ldi temporary1,(1**twint)+(1**twen)+(1**twsto)
out twcr,temporary1 ;set stop condition
pop temporary1
retopen_DS_to_read_write:
ldi temporary1,1**twen ;TW enable
out twcr,temporary1ldi temporary1,(1**twsta)+(1**twen)+(1**twint)
rcall wait_twint_one
ldi temporary1,0b11010000 ;sta+w
out twdr,temporary1
ldi temporary1,(1**twint)+(1**twen)rcall wait_twint_one
out twdr,yl
ldi temporary1,(1**twint)+(1**twen)rcall wait_twint_one
retload_real_time_now:
push temporary3
push yl
push r0
push r1
ldi yl,ds_sec_addr
rcall read_DS_data
mov temporary3,temporary1wait_sec_to_next:
ldi yl,ds_sec_addr
rcall read_DS_data
cp temporary1,temporary3
breq wait_sec_to_nextrcall convert_to_true_binary
sts secoonds_,temporary1ldi yl,ds_min_addr
rcall read_DS_datarcall convert_to_true_binary
sts minutes_,temporary1ldi yl,ds_hour_addr
rcall read_DS_datarcall convert_to_true_binary
sts hours_,temporary1ldi yl,ds_days_addr
rcall read_DS_datarcall convert_to_true_binary
sts days_,temporary1ldi yl,ds_month_addr
rcall read_DS_datarcall convert_to_true_binary
sts month_,temporary1ldi yl,ds_jear_addr
rcall read_DS_datarcall convert_to_true_binary
sts jear_,temporary1
pop r1
pop r0
pop yl
pop temporary3
ret
convert_to_true_binary:
push temporary1
andi temporary1,$f0
swap temporary1
ldi temporary3,10
mul temporary1,temporary3
pop temporary1
andi temporary1,$0f
add temporary1,r0
ret
E-mail: info@telesys.ru