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.
Start by determining the 16-bit value that will give you a 1Hz timeout. This is dependent on the clock frequency, which if it's a stock 6522 would be 1MHz. Disable Timer 1 interrupts in the IER unless you want/need to respond to a timeout interrupt. Set the ACR for the proper mode (probably $C0 for free-running, PB7 output enabled). Then, store the count value in register address +4 and +5 (low byte and high byte latches). Writing to the high-order latch starts the counter. PB7 is the output pin which may need conditioning/buffering depending on the circuit loading.
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
Build Master and maintainer of the Altair32 Emulation project
http://cini.classiccmp.orghttp://altair32.classiccmp.org