|
Post by cagroundhog on Dec 19, 2020 4:39:26 GMT
I am making a video on the C64 Time of Day clock but I've been running in to problems.
The memory locations as follows: $DC0B HOURS
$DC0A MINUTES
$DC09 SECONDS
$DC08 TENS OF SECONDS
$DCOD CIA INTERUPT CONTROL REGISTER
$DCOF CONTROL REGISTER B
When setting the alarm on the C64 it doesn't appear to be reliable.
I set CRB to hex $88 10001000 setting bit 7, bit 3 seems to be set by default so I don't change it.
Then I set the hours, minutes, seconds and tens of seconds to BCD format within the limits of each register HEX 92:59:59:9.
Then I check CIAICR for bit 2 (3rd bit from the right) to be set. Which should indicate the alarm time has been reached.
It works 50% of the time, roughly. It's very confusing, I can't seem to pinpoint why it won't work half the time.
Any advice would be greatly appreciated and listed in the video credits.
|
|
|
Post by bjonte on Dec 19, 2020 11:20:24 GMT
You seem to be doing the right thing. What isn’t working? Do you get the alarm too soon or too late or not at all?
Do you clear the interrupt bit before setting the alarm?
Do you write hours first and tenths of seconds last?
Are you making sure nothing else is poking around in the timer registers in an interrupt? The kernal is using a timer interrupt to read the keyboard. Have you disabled that?
|
|
|
Post by cagroundhog on Dec 21, 2020 5:43:13 GMT
You seem to be doing the right thing. What isn’t working? Do you get the alarm too soon or too late or not at all? Do you clear the interrupt bit before setting the alarm? Do you write hours first and tenths of seconds last? Are you making sure nothing else is poking around in the timer registers in an interrupt? The kernal is using a timer interrupt to read the keyboard. Have you disabled that? Here’s an example, let’s say from a fresh boot I poke CRB with $88, 10001000, poke the hours with $1, poke the minutes with $1, poke the seconds $0, poke the tens of seconds $0. Alarm should be set for 01:01:00:00am When you boot the C64, time starts at 01:00:00:00am, boot meaning full power cycle with the power switch not a reset button. So now I poke CRB with $8 and poke the tens of seconds register with $0 to kick start the clock. Alarm time passes, CIAICR bit 2 (3rd bit from right) never sets to indicate the alarm time was reached. Ok so now I did it, I did it wrong. I didn’t set the clock by hours, minutes, seconds and tens of seconds. Fair enough. At this point, no matter, even if I set all registers perfectly in order, even set CIAICR with $85 10000011 or even $84 nothing I do will make bit 2 of the CIAICR trigger at alarm time unless I reboot the computer and do everything properly, set time, set CRB, set alarm, then it will work. Ok so what happens if I set everything properly each time after a fresh boot. This is where it gets tricky, I can't explain it because I can't replicate the behavior dependably. Eventually bit 2 of the CIAICR still wont signal that the alarm time was reached and nothing will fix it except a reboot again.
I wrote a program that will set the time to 6:00:00:00am and the program sets the clock only once but sets the alarm one minute in the future every time the CIAICR bit 2 reads true. So it keeps setting another minute in the future over and over. Well it worked 9 times in a row, no problem. Now when I exit the program and start setting the clock and then setting the alarm it'll break, from there if I start my program that previously worked 9 times in a row, it then doesn't work at all.
Honestly just kick starting the time with a poke to the tens of seconds register shouldn’t break the alarm.
I’m using the kickstart of tens of seconds register as an example here, because this is the only method I can find that will dependably break the alarm. I don’t know any other way to get a consistent result.
|
|