Tape pulse IRQ timer jitteritis – and I(R)Q test

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
pixel
Vic 20 Scientist
Posts: 1330
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Tape pulse IRQ timer jitteritis – and I(R)Q test

Post by pixel »

Yes, another IRQ jitter dilemma. After reading a couple of threads I assumed that this code would give me a jitter of up to three cycles, but it actually jitters up to 21 cycles. Why? :(

TAP file: http://hugbox.org/pixel/external/denial/jitter.tap

Code: Select all

timer = @(* 8 #x28)

main:
    sei
    lda #$7f
    sta $911e
    sta $912e
    sta $912d

    ; Start tape motor.
    lda $911c
    and #$fd
    sta $911c

    ; Set IRQ vector.
    lda #<irq
    sta $314
    lda #>irq
    sta $315

    ; Initialise VIA2 Timer 1 (cassette tape read).
    lda #<timer     ; Cycles to count down.
    sta $9124
    lda #>timer
    sta $9125
    lda #%00000000  ; One-shot mode.
    sta $912b

    ; Initialize VIA2 tape pulse IRQ.
    lda #%10000010  ; CA1 IRQ enable (tape pulse)
    sta $912e

    ; Giz a 3 cycle jitter? No…
    cli
w:  bne -w

; Reads pulses of length $20 (256 cycles).                                      
irq:lda $9124       ; VIA2 timer 1 low byte.
    ldy #>timer
    sty $9125       ; Restart the timer.

l:  sta $1e00
    inc @(++ -l)

    lda #$7f        ; Acknowledge pulse interrupt.
    sta $912d
    jmp $eb18
Last edited by pixel on Thu Oct 22, 2015 11:39 am, edited 1 time in total.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
groepaz
Vic 20 Scientist
Posts: 1180
Joined: Wed Aug 25, 2010 5:30 pm

Re: Tape pulse IRQ timer jitteritis

Post by groepaz »

timer = @(* 8 #x28)
what kind of evil witchcraft syntax from hell is that? :)

Code: Select all

l:  sta $1e00
    inc @(++ -l)
... or this? /o\

i'd use something like this:

Code: Select all

    tax
    inc $1e00,x
to show the different timer values you get. if there are more than 7 different ones, then there is certainly some other problem than irq latency :)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
pixel
Vic 20 Scientist
Posts: 1330
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Tape pulse IRQ timer jitteritis

Post by pixel »

groepaz wrote:
timer = @(* 8 #x28)
what kind of evil witchcraft syntax from hell is that? :)
That's inlined Lisp meaning "8 * $28". Sorry. The other one was… well, you figured it out already. :cool:
if there are more than 7 different ones, then there is certainly some other problem than irq latency :)
Oh, blimey! Your version made it very obvious: the timer jitters along in values three cycles apart from each other. m) Will get that fixed in just a couple of days now. :roll:

EDIT: Thanks! ;)
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
Post Reply