6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue May 21, 2024 10:56 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Nov 25, 2023 2:40 am 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
I ran into something unexpected yesterday when programming a WDC 65C22's T1 for repeated short delays, and wondered whether anybody else had seen it.

I had configured T1 to generate continuous interrupts (ACR = $40) but had not enabled them in the IER - I was just polling the bits in the IFR to see when it expired. The T1 latch value was fairly small, e.g. 20 cycles.

At certain points I'd want to reset T1 to begin its count again in sync with something else, and then later wait for it to expire, like this:

Code:
    STZ VIA_T1CH
    ... other things ...
loop:
    BIT VIA_IFR
    BVC loop

However, I found at least in some cases that the STZ was not clearing the IFR bit - the loop would seem to exit too soon. I suspected that it could be due to the timer happening to expire at just the same moment that I reset it, but I'm not sure and I didn't specifically try to verify that.

Adding an extra BIT T1CL instruction after the STZ seemed to fix the problem. But it surprised me that this occurred, and I wondered whether it was common knowledge that this extra step was required here.


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 25, 2023 3:29 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8442
Location: Southern California
With a quick (not thorough) look at past work, it looks like I've always just read the timer's low counter byte to clear the interrupt.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: