грёбаный НТМЛ!!! 2*< = **
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено =mse= 31 марта 2004 г. 16:57
В ответ на: DS1307@M163 отправлено =mse= 31 марта 2004 г. 16:53


read_DS_data:
rcall open_DS_to_read_write
ldi temporary1,(1**twsta)+(1**twen)+(1**twint)
rcall wait_twint_one

ldi temporary1,0b11010001 ;SLA + R
out twdr,temporary1 ;select DS
ldi temporary1,(1**twint)+(1**twen) ;SLA+R send start

rcall 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
ret

wait_twint_one:
out twcr,temporary1

wait_twint_one__:
in temporary1,twcr
sbrs temporary1,twint
rjmp wait_twint_one__
ret


write_DS_data:
push temporary1
rcall open_DS_to_read_write

pop 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
ret

open_DS_to_read_write:
ldi temporary1,1**twen ;TW enable
out twcr,temporary1

ldi 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
ret

load_real_time_now:
push temporary3
push yl
push r0
push r1
ldi yl,ds_sec_addr
rcall read_DS_data
mov temporary3,temporary1

wait_sec_to_next:
ldi yl,ds_sec_addr
rcall read_DS_data
cp temporary1,temporary3
breq wait_sec_to_next

rcall convert_to_true_binary
sts secoonds_,temporary1

ldi yl,ds_min_addr
rcall read_DS_data

rcall convert_to_true_binary
sts minutes_,temporary1

ldi yl,ds_hour_addr
rcall read_DS_data

rcall convert_to_true_binary
sts hours_,temporary1

ldi yl,ds_days_addr
rcall read_DS_data

rcall convert_to_true_binary
sts days_,temporary1

ldi yl,ds_month_addr
rcall read_DS_data

rcall convert_to_true_binary
sts month_,temporary1

ldi yl,ds_jear_addr
rcall read_DS_data

rcall 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