Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user eightbitswide ! (Registered 2024-12-24) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Setting up a timer interrupt
2004-03-14 22:48
Hurrican

Registered: Oct 2003
Posts: 10
Setting up a timer interrupt

Hello *.*,

I'm trying to set up a timer interrupt to make something happen at a regular basis (let's say: every 5 seconds). I already managed to do a raster interrupt, but setting up a timer interrupt beats me. After browsing the web I came up with this code:

----------------------8<----------------------8<---------

inittint lda #$7f
sta $dc0d ; disable cia1 int

lda $dc0e
and #$be
sta $dc0e ; stop timer a

lda $dc0f
and #$be
sta $dc0f ; stop timer b

lda #$00
sta $dc05 ; hibyte timer
lda #$ff
sta $dc04 ; lobyte timer

lda #<inthand
sta $0318
lda #>inthand
sta $0319 ; set t-int handler

lda $dc0e
and #$80
ora #$11
ldx #$81

stx $dc0d ; enable timer int
sta $dc0e ; start timer a

loop jmp loop

inthand lda $dc0d ; interrupt-source?
and #%00000001
beq timerint
rti

timerint jsr *fancy_stuff*
rti

----------------------8<----------------------8<---------

After running the program, the interrupt never seems to occur. Now, what's my mistake?

I assume I'm making a fool out of me for asking that question, but that's no problem for me... ;-)
 
... 10 posts hidden. Click here to view all posts....
 
2006-01-11 08:50
HCL

Registered: Feb 2003
Posts: 728
I'm not sure $0314-15 works at all, never used them a.f.a.i.can.remember. And.. why try now, after 15 years !? ;).
2006-01-11 09:17
Oswald

Registered: Apr 2002
Posts: 5094
hahaha

I've started with 0314/15, but now Im also unsure wether it would work at all, fffe/ffff is my cosy territory, after all those years 314/15 is scarry :D
2006-01-11 09:38
Krill

Registered: Apr 2002
Posts: 2980
i second jackasser... there are times when the kernal vectors just come in super-handy. :D and yes, of course they work.
2006-01-11 09:42
Compyx

Registered: Jan 2005
Posts: 631
When writing programs like editors, you'll more or less have to use $0314/$0315 to be able to use kernal-routines like GETIN (scanning the keyboard queue).

When you look at $fffe/$ffff you'll see it points to $ff48 which in turn JMP's to ($0314) or ($0316) when bit 4 of P is set (BRK).

So you're basically rerouting the kernal interrupt handler when setting $0314/$0315. There's no need to use $ea31 unless you're using GETIN, $ea81 is sufficient as it pulls A,X and Y from the stack which were pushed on it by $ff48.

Just my 2 cents ;)
2006-01-11 10:40
Ninja

Registered: Jan 2002
Posts: 411
Dunno if your 5-second-interval is the true value, but if it is then one timer won't be enough, as it can just count 65536 cycles. So, either you combine two timers (Timer B counts underruns of Timer A) or you use the Time-of-day-Clock.
2006-01-11 15:26
Graham
Account closed

Registered: Dec 2002
Posts: 990
WHAAAAH no TOD clock please :D inaccurate as hell
2006-01-11 15:57
Oswald

Registered: Apr 2002
Posts: 5094
compyx: you can call yourself SCNKEY, so u can use GETIN. no need for kernal interrupt.
2006-01-11 16:05
Ninja

Registered: Jan 2002
Posts: 411
Well, okay, I assumed that a 5-second-interval could also live with some tolerance, hence mentioning the TOD. If it needs to be more exact, combinig timers is inevitable.
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Magic/Nah-Kolor
Kickback
Guests online: 109
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 X-Mas Demo 2024  (9.5)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Mutetus  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Stinsen  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.065 sec.