From: Will Sowerbutts Date: Wed, 25 Jan 2017 14:36:50 +0000 (+0000) Subject: Kernel: p112: Fix timer interrupt rate X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=2f899edfb6029a60b7d2d4920949b416332833e5;p=FUZIX.git Kernel: p112: Fix timer interrupt rate --- diff --git a/Kernel/cpu-z180/z180.s b/Kernel/cpu-z180/z180.s index c427fec3..967ab13b 100644 --- a/Kernel/cpu-z180/z180.s +++ b/Kernel/cpu-z180/z180.s @@ -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 diff --git a/Kernel/platform-p112/kernel.def b/Kernel/platform-p112/kernel.def index bb1368ac..dfcbfa63 100644 --- a/Kernel/platform-p112/kernel.def +++ b/Kernel/platform-p112/kernel.def @@ -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