EtchedPixels / FUZIX

FuzixOS: Because Small Is Beautiful
Other
2.18k stars 272 forks source link

sc111: fix PRT timer interrupt flag reset #972

Closed ra1fh closed 1 year ago

ra1fh commented 1 year ago

To reset the timer interrupt, read TCR first and then TMDR0L. Otherwise, on Z8S180-K the timer interrupt triggers with double of the intended frequency.

ra1fh commented 1 year ago

The official documentation is not very clear about the ordering. Some Z180 manuals contain a timing diagram that shows TCR first and TMDR second. I could only find one source about HD64180 that mentions that order is important:

https://oldcomputers.dyndns.org/public/pub/rechner/eaca/common/user-clubs/club-80/hardwarespezial(html)/hd64180-sonderinfo/hd64180-20-timer.htm

ra1fh commented 1 year ago

This was found with ds1302 enabled btw. The time quickly ran away and started to jump centuries when the timer interrupt triggered too fast. With the fix in place, ds1302 works fine.

EtchedPixels commented 1 year ago

Interesting little quirk. I'll go ripple that through the other Z180 ports