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.