ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Пятница
19 июля
11943 Топик полностью
=mse= (27.07.2004 10:39, просмотров: 1) ответил Паныч на Мы тоже :) прога, использующая аппаратную поддержку с прерываниями, отвечающая на появление состояний установкой флагов
есть, но АСМ и поллинг (без прерываний) работа с DS1307(кажись такая фамилия)
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