Kernel: p112: Fix timer interrupt rate
authorWill Sowerbutts <will@sowerbutts.com>
Wed, 25 Jan 2017 14:36:50 +0000 (14:36 +0000)
committerWill Sowerbutts <will@sowerbutts.com>
Wed, 25 Jan 2017 14:37:18 +0000 (14:37 +0000)
Kernel/cpu-z180/z180.s
Kernel/platform-p112/kernel.def

index c427fec..967ab13 100644 (file)
@@ -177,7 +177,7 @@ z180_init_hardware:
         ; set up system tick timer
         xor a
         out0 (TIME_TCR), a
-        ld hl, #(CPU_CLOCK_KHZ * (1000/20) / TICKSPERSEC) ; timer ticks at PHI/20
+        ld hl, #((CPU_CLOCK_KHZ * (1000/Z180_TIMER_SCALE) / TICKSPERSEC) - 1)
         out0 (TIME_RLDR0L), l
         out0 (TIME_RLDR0H), h
         ld a, #0x11         ; enable downcounting and interrupts for timer 0 only
index bb1368a..dfcbfa6 100644 (file)
@@ -14,6 +14,7 @@ Z80_TYPE                  .equ 2
 ; (18.432MHz) but this made the machine unstable.
 USE_FANCY_MONITOR           .equ 1            ; disabling this saves around 0.5KB
 CPU_CLOCK_KHZ               .equ 16000        ; 16MHz is the stock crystal
+Z180_TIMER_SCALE            .equ 10           ; CPU clocks per timer tick
 TICKSPERSEC                 .equ 40           ; timer interrupt rate (Hz)
 
 PROGBASE                   .equ 0x0000