IGNORED

# Questions about using the timer.

## Recommended Posts

Hi, I'm seeing examples of code that use TIM64T and INTIM. I'm reading page 12 of the Stella's Programming Guide. I'm not sure I understand what it all means. It sounds like any number you move into one of the interval timers gets multiplied by that interval and starts counting down to zero. So, page 12 says if I load #100 to TIM64T, then the timer would start counting down from 6400 clocks to zero. I'm confused about what a "clock" is. Is a clock one cpu cycle? So loading #100 to TIM64T would be 6400 CPU cycles?

Another thing I am not clear on is, when the timer reaches zero, the Guide says "It holds that count for one interval". Is an interval one cpu cycle or is it 64 cpu cycles?

Jim

##### Share on other sites

Yup.

Is an interval one cpu cycle or is it 64 cpu cycles?

Yes, for TIM64T it is 64 cycles.

##### Share on other sites

Great! So I'm thinking that after the last WSYNC of Vblank, if I load the correct number into TIM64T, then that will count down through all the cpu cycles of the visible 192 scanlines.

192 * 76 cycles is 14592 / 64 = 228.

sample code might look like this?

```
sta WSYNC;last wsync of the vertical blank
;in this example I think lda takes 2 cycles and sta takes 3 cycles
;so I have to subtract 5 from 76 to get 71 cycles.
;71 * 192 = 13632
;13632 / 64 = 213
lda #213
sta TIM64T

LOOP

;do some stuff

lda INTIM
bne LOOP

;we should be at the last visible scanline

OverScan

```

Does this look right?

jim

##### Share on other sites

192 * 76 cycles is 14592 / 64 = 228.

No, you should still load 228, by using 213 you will loose about 4 scanlines (5*64 = ~4*76). And finally do one WSYNC do hit the exact end of the last scanline.

BTW: Since the timer will go from 218 to 217 immediately, you will actually only wait for 217 timer loops.

##### Share on other sites

BTW: Since the timer will go from 218 to 217 immediately, you will actually only wait for 217 timer loops.

Where did you get 218 or did you mean 228?

##### Share on other sites

Where did you get 218...?

Where you got the 213: By mistake!

228 is correct.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×