6522 VIA timer
6522 VIA timer
I am thinking of building a 6502-based digital clock. For the timing, I would like the timing to be done by a 6522 VIA. How do I program Timer 1 of the 6522 to tick once a second? Oh, and I don't want to use any approaches that modify PA or PB, since I'd like to hook up those to a BCD decoder.
Sam
---
"OK, let's see, A0 on the 6502 goes to the ROM. Now where was that reset vector?"
---
"OK, let's see, A0 on the 6502 goes to the ROM. Now where was that reset vector?"
Re: 6522 VIA timer
asmlang_6 wrote:
I am thinking of building a 6502-based digital clock. For the timing, I would like the timing to be done by a 6522 VIA. How do I program Timer 1 of the 6522 to tick once a second? Oh, and I don't want to use any approaches that modify PA or PB, since I'd like to hook up those to a BCD decoder.
Although I haven't pulled the 6522 data sheet, as I recall it had some good information on this (no code unfortunately), but it's pretty straightforward.
Rich Cini
http://cini.classiccmp.org
http://altair32.classiccmp.org
GitHub Repro: https://github.com/RichCini
http://cini.classiccmp.org
http://altair32.classiccmp.org
GitHub Repro: https://github.com/RichCini
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Quote:
How do I program Timer 1 of the 6522 to tick once a second?
The 6522 VIA's T1 can be used in different ways, including free-running with the time-out frequency being determined by the phase-2 frequency and the T1 latch value you store. (The time-out frequency is actually ph2/(n+2), where ph2 is the phase-2 frequency, and n is the latch value. The latch (and counter) however, being only 16-bit, cannot count nearly high enough to go a whole second unless the clock frequency is really low. On my 5MHz workbench computer, I have VIA1 cause an interrupt every 10ms (.01 second) for keeping time, since the VIA can't even count up to the next round number of 20ms at 5MHz, or even to 1/60th of a second. Every time T1 times out, an interrupt is generated, and software updates the memory locations that keep the time from the hundredths-of-seconds place to the years' place. This is covered in the 6502 interrupts primer, which also covers the code for how to set up the 6522. The "Tip of the Day" column at http://www.6502.org/forum/viewtopic.php?t=342 may also be helpful, particularly tips numbers 9 and 21. (The purpose of the "Tip of the Day" was to give ideas of what can be done, not to give all the details of how.)
Quote:
since I'd like to hook up those to a BCD decoder.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?