🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #10940

Re: ciatimer.c - Another bug

#10940
From: C. Harald Koch
Date: Fri, 13 Jan 1989 17:33
39 lines
2143 bytes
There is a bug in StartCIATimer() that only shows up when you try to switch
to Timer B on either CIA. Here is the offending code:

>/* start the timer, clear pending interrupts, and enable timer A
> * Interrupts */
>StartCIATimer()
>{
>	ciacr &= ~(CIACRAF_RUNMODE);	/* set it to reload on overflow */
>	ciacr |= (CIACRAF_LOAD | CIAICRF_TA);
                                 ^^^^^^^^^^
>	SetICR(CIAResource,CLEAR|CIAICRF_TA);
>	AbleICR(CIAResource, CIAICRF_SETCLR | CIAICRF_TA);
>}

What we are trying to do in this statement is start the timer. To start the
timer, we set bit 0 in the appropriate timer control register (ciacr points
to this).  The flags CIAICRF_TA just *happens* to be bit 0, so this works
for Timer A.  However, CIAICRF_TB is bit 1, which causes the timer B output
to appear on line 7 of the parallel port. On CIAB, this is the disk motor
control, so when we change the code to use TimerB on CIAB, the disk motor
starts, not the timer.

The CIAICRF_ flags are for the interrupt control register, not the timer
control registers. The correct flag in this case is CIACRAF_START or
CIACRBF_START, depending on which timer you are using. The statement becomes

>	ciacr |= (CIACRAF_LOAD | CIACRAF_START);

And everything works hunky-dory.

Note that in StopCIATimer() the START bit is cleared correctly... This bug
seems to be a simple oversight on karl@sugar's part.

Disclaimer: I didn't find this bug; Kodiak pointed it out to me via E-Mail
after I described the symptoms to him. Thanks, Kodiak!
-- 
C. Harald Koch		NTT Systems, Inc., Toronto, Ontario
chk@zorac.dciem.dnd.ca, chk@gpu.utcs.toronto.edu, chk@chkent.UUCP
"I give you my phone number. If you worry, call me. I'll make you happy."
Technical Details
Message-ID: <1367@dretor.dciem.dnd.ca>
Path: arc1-ca.pugleaf.net!utzoo!dciem!dretor!chk
References: <3236@sugar.uu.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!dciem!dretor!chk
From: chk@dretor.dciem.dnd.ca (C. Harald Koch)
Newsgroups: comp.sys.amiga.tech
Subject: Re: ciatimer.c - Another bug
Message-ID: <1367@dretor.dciem.dnd.ca>
Date: 13 Jan 89 17:33:38 GMT
Article-I.D.: dretor.1367
References: <3236@sugar.uu.net>
Reply-To: chk@dretor.dciem.dnd.ca (C. Harald Koch)
Organization: NTT Systems, Inc., Toronto, Canada
Lines: 39