mirror of https://github.com/mgcaret/of816.git
Neon816: replace buggy clock code; add MS delay word to platform
This commit is contained in:
parent
367ec0d98d
commit
5750e5d12f
|
@ -124,42 +124,94 @@ dword dKBDRESET,"$KBDRESET"
|
||||||
eword
|
eword
|
||||||
|
|
||||||
; H: ( day hour minutes seconds ms us -- ) set RTC
|
; H: ( day hour minutes seconds ms us -- ) set RTC
|
||||||
; this probably isn't fast enough to reliably set micro and milliseconds
|
; The registers must be set starting with the microseconds and ending with the day
|
||||||
|
; when the day is written the clock registers are copied to the internal registers
|
||||||
dword SETRTC,"SETRTC"
|
dword SETRTC,"SETRTC"
|
||||||
ENTER
|
txa
|
||||||
ONLIT RTCus
|
clc
|
||||||
.dword WSTORE
|
adc #20
|
||||||
ONLIT RTCms
|
cmp STK_TOP
|
||||||
.dword WSTORE
|
bcc :+
|
||||||
ONLIT RTCsec
|
jmp _stku_err
|
||||||
.dword CSTORE
|
: lda STACKBASE+0,x
|
||||||
ONLIT RTCmin
|
sta RTCus
|
||||||
.dword CSTORE
|
lda STACKBASE+4,x
|
||||||
ONLIT RTChour
|
sta RTCms
|
||||||
.dword CSTORE
|
sep #SHORT_A
|
||||||
ONLIT RTCday
|
.a8
|
||||||
.dword WSTORE
|
lda STACKBASE+8,x
|
||||||
EXIT
|
sta RTCsec
|
||||||
|
lda STACKBASE+12,x
|
||||||
|
sta RTCmin
|
||||||
|
lda STACKBASE+16,x
|
||||||
|
sta RTChour
|
||||||
|
rep #SHORT_A
|
||||||
|
.a16
|
||||||
|
lda STACKBASE+20,x
|
||||||
|
sta RTCday
|
||||||
|
txa
|
||||||
|
clc
|
||||||
|
adc #24
|
||||||
|
tax
|
||||||
|
NEXT
|
||||||
eword
|
eword
|
||||||
|
|
||||||
; H: ( -- day hour minutes seconds ms us ) get RTC
|
; H: ( -- day hour minutes seconds ms us ) get RTC
|
||||||
|
; The registers must be read starting with the microseconds to copy the internal
|
||||||
|
; registers to the clock registers.
|
||||||
dword GETRTC,"GETRTC"
|
dword GETRTC,"GETRTC"
|
||||||
ENTER
|
lda #$0000
|
||||||
ONLIT RTCday
|
tay
|
||||||
.dword WFETCH
|
jsr _pushay
|
||||||
ONLIT RTChour
|
jsr _pushay
|
||||||
.dword CFETCH
|
jsr _pushay
|
||||||
ONLIT RTCmin
|
jsr _pushay
|
||||||
.dword CFETCH
|
jsr _pushay
|
||||||
ONLIT RTCsec
|
jsr _pushay
|
||||||
.dword CFETCH
|
lda RTCus
|
||||||
ONLIT RTCms
|
sta STACKBASE+0,x
|
||||||
.dword WFETCH
|
lda RTCms
|
||||||
ONLIT RTCus
|
sta STACKBASE+4,x
|
||||||
.dword WFETCH
|
sep #SHORT_A
|
||||||
EXIT
|
.a8
|
||||||
|
lda RTCsec
|
||||||
|
sta STACKBASE+8,x
|
||||||
|
lda RTCmin
|
||||||
|
sta STACKBASE+12,x
|
||||||
|
lda RTChour
|
||||||
|
sta STACKBASE+16,x
|
||||||
|
rep #SHORT_A
|
||||||
|
.a16
|
||||||
|
lda RTCday
|
||||||
|
sta STACKBASE+20,x
|
||||||
|
NEXT
|
||||||
eword
|
eword
|
||||||
|
|
||||||
|
.proc _getms
|
||||||
|
lda RTCus ; latch clock registers
|
||||||
|
lda RTCms ; get ms
|
||||||
|
rts
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
; waits for up to 511 ms (ms timer is 0-999)
|
||||||
|
.proc _mswait
|
||||||
|
and #$1FF
|
||||||
|
beq :++
|
||||||
|
pha
|
||||||
|
jsr _getms
|
||||||
|
and #$1FF
|
||||||
|
pha
|
||||||
|
: jsr _getms
|
||||||
|
sec ; should we worry about 1 ms?
|
||||||
|
sbc 1,s
|
||||||
|
and #$1FF
|
||||||
|
cmp 3,s
|
||||||
|
bcc :-
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
: rts
|
||||||
|
.endproc
|
||||||
|
|
||||||
; NOTE: sets short accumulator and leaves it that way on exit!
|
; NOTE: sets short accumulator and leaves it that way on exit!
|
||||||
.proc I2C2_busy_wait
|
.proc I2C2_busy_wait
|
||||||
sep #SHORT_A
|
sep #SHORT_A
|
||||||
|
@ -555,8 +607,6 @@ table: .addr _sf_pre_init
|
||||||
.dword drXT ; last word defined in the neon816 dictionary
|
.dword drXT ; last word defined in the neon816 dictionary
|
||||||
.dword rBODY
|
.dword rBODY
|
||||||
.dword STORE
|
.dword STORE
|
||||||
.dword GETRTC ; start the clock
|
|
||||||
.dword CLEAR
|
|
||||||
CODE
|
CODE
|
||||||
jmp _sf_success
|
jmp _sf_success
|
||||||
.endproc
|
.endproc
|
||||||
|
|
|
@ -1,2 +1,24 @@
|
||||||
; Platform support dictionary words for Neon816
|
; Platform support dictionary words for Neon816
|
||||||
|
|
||||||
|
dword MS,"MS"
|
||||||
|
stz WR+2
|
||||||
|
jsr _popay
|
||||||
|
sta WR+1
|
||||||
|
tya
|
||||||
|
xba
|
||||||
|
sep #SHORT_A
|
||||||
|
.a8
|
||||||
|
sta WR
|
||||||
|
rep #SHORT_A
|
||||||
|
.a16
|
||||||
|
tya
|
||||||
|
and #$00FF ; do the first 1-255 ms
|
||||||
|
: jsr _mswait
|
||||||
|
lda WR
|
||||||
|
ora WR+1
|
||||||
|
beq :+ ; done if WR is zero
|
||||||
|
jsr _decwr
|
||||||
|
lda #$0100
|
||||||
|
bra :-
|
||||||
|
: NEXT
|
||||||
|
eword
|
||||||
|
|
Loading…
Reference in New Issue