|
|
Korektne rutinky na pracu s RTC
Verzia 03
Vseobecna schema prace s hodinkami:
- Test ci je vobec instalovane RTC
call rtcini
jr nz,uzivatel_ma_smolu
- Test ci uz treba vypisat casovy udaj
loop hlt
call rtctst
jr z,loop
- Precitanie casoveho udaja
ld hl,buffer
call rdrtc
jr nz,chyba_pri_citani
- Vypis casoveho udaja
..vypis..
jp loop
Ak chceme nastavit hodinky:
ld hl,buffer
call rdrtc
jr nz,chyba_pri_citani
..nastavenie buffera..
ld hl,buffer
call wrrtc
V okamihu vykonania wrrtc zacne cas plynut od daneho nastavenia.
To nacitanie buffera pred jeho nastavenim je v podstate nepovinne.
buffer ds #0d
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sec01 = buffer+#00 0-9 jednotky sekund
sec10 = buffer+#01 0-5 desiatky sekund
min01 = buffer+#02 0-9 jednotky minut
min10 = buffer+#03 0-5 desiatky minut
hod01 = buffer+#04 0-9 ...atd...
hod10 = buffer+#05 0-2
den01 = buffer+#06 0-9
den10 = buffer+#07 0-3
mes01 = buffer+#08 0-9
mes10 = buffer+#09 0-1
rok01 = buffer+#0A 0-9 (Skutocny rok = 1900+rok ak rok>79)
rok10 = buffer+#0B 0-9 2000+rok ak rok<80)
dentt = buffer+#0C 0-6 (0=nedela;1=pondelok;...;6=sobota)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
592 08a1 -----------
593 08a1 01030e rtcini ld bc,#0e00+rtc Test RTC (ci je installnute)
594 08a4 1e50 ld e,#50 a jeho inicializacia
595 08a6 ed59 rtcii1 out (c),e
596 08a8 ed78 in a,(c) Out: Z = RTC je ready
597 08aa 57 ld d,a NZ = RTC not present
598 08ab e60f and #0f
599 08ad f650 or #50
600 08af ab xor e
601 08b0 c0 ret nz
602 08b1 1c inc e
603 08b2 7b ld a,e
604 08b3 e60f and #0f
605 08b5 20ef jr nz,rtcii1
606 08b7 04 inc b Naprogramovanie
607 08b8 3e04 ld a,#04 riadiacich
608 08ba ed79 out (c),a registrov
609 08bc 05 dec b
610 08bd 3e06 ld a,#06
611 08bf ed79 out (c),a
612 08c1 05 dec b
613 08c2 af xor a
614 08c3 ed79 out (c),a
615 08c5 c9 ret
616 08c6
617 08c6 01030d rtctst ld bc,#0d00+rtc Test ci sa uz
618 08c9 ed58 in e,(c) zmenil casovy udaj
619 08cb cb53 bit 2,e
620 08cd c8 ret z z .. nezmenil
621 08ce 1e02 ld e,#02 nz ... zmenil
622 08d0 ed59 out (c),e
623 08d2 c9 ret
624 08d3
625 08d3 01030f wrrtc ld bc,#0f00+rtc Zapisanie casu do RTC
626 08d6 3e05 ld a,#05 Vstup: hl=buffer
627 08d8 ed79 out (c),a
628 08da 0600 ld b,#00
629 08dc 7e rtcww1 ld a,(hl)
630 08dd ed79 out (c),a
631 08df 23 inc hl
632 08e0 04 inc b
633 08e1 78 ld a,b
634 08e2 fe0d cp #0d
635 08e4 38f6 jr c,rtcww1
636 08e6 3e04 ld a,#04
637 08e8 060f ld b,#0f
638 08ea ed79 out (c),a
639 08ec c9 ret
640 08ed
641 08ed 1e10 rdrtc ld e,#10 Precitanie casu z RTC
642 08ef 22f308 ld (rtcrr1+1),hl Vstup: hl=buffer
643 08f2 215555 rtcrr1 ld hl,#5555 Vystup: Z = platne udaje v bufferi
644 08f5 01030d ld bc,#0d00+rtc NZ = nepodarilo sa precitat
645 08f8 af xor a
646 08f9 ed79 out (c),a
647 08fb 47 ld b,a
648 08fc ed78 rtcrr2 in a,(c)
649 08fe e60f and #0f
650 0900 77 ld (hl),a
651 0901 23 inc hl
652 0902 04 inc b
653 0903 78 ld a,b
654 0904 fe0d cp #0d
655 0906 38f4 jr c,rtcrr2
656 0908 ed78 in a,(c)
657 090a cb57 bit 2,a
658 090c c8 ret z
659 090d 1d dec e
660 090e 20e2 jr nz,rtcrr1
661 0910 b1 or c
662 0911 c9 ret
663 0912 -----------
988 00a0 rtc = #03 definicia portu
|
|
|