From: Kevin M. Rosenberg Date: Fri, 9 Mar 2007 14:53:51 +0000 (+0000) Subject: r11571: fix div by zero X-Git-Tag: v0.1.3~5 X-Git-Url: http://git.kpe.io/?p=cluck.git;a=commitdiff_plain;h=462145e6346a84286992a99ef71e0584485a55a2 r11571: fix div by zero --- diff --git a/cluck.lisp b/cluck.lisp index dff957e..1267bd1 100644 --- a/cluck.lisp +++ b/cluck.lisp @@ -38,7 +38,7 @@ (defpackage #:cluck (:use #:cl) - (:export + (:export #:show-timers #:show-8-bit-timers #:show-16-bit-timers @@ -57,7 +57,7 @@ (defvar *base-error-zero-baud-clk* (* 9 25 8192) "Base multiple for multi-megahertz clock frequencies to have -0% error at common UART baud rates. Value of this base is 1.8432 million. +0% error at common UART baud rates. Value of this base is 1.8432 million. Common multiples of this are 2 (3.6864Mhz), 4 (7.3728Mhz), 8 (14745600), and 10 (18.432MHz)") @@ -126,9 +126,9 @@ controllers, 32-bit timers use 8-bit prescalers" rates for F_CPU. UBBR is limited to 12 bits." (dolist (baud *baud-rates*) (let* ((ubrr (min 4096 - (round (- (/ f-cpu 16 baud) 1)))) + (max 0 (round (- (/ f-cpu 16 baud) 1))))) (ubrr2 (min 4096 - (round (- (/ f-cpu 8 baud) 1)))) + (max 0 (round (- (/ f-cpu 8 baud) 1))))) (actual-baud (/ f-cpu 16 (1+ ubrr))) (actual-baud2 (/ f-cpu 8 (1+ ubrr2))) (err (* 100 (- (/ actual-baud baud) 1))) @@ -144,10 +144,10 @@ rates for F_CPU. UBBR is limited to 12 bits." rates for Fcy. BRG is limited to 16 bits." (dolist (baud *baud-rates*) (let* ((brg (min 65536 - (max 1 (round (- (/ fcy 16 baud) 1))))) + (max 0 (round (- (/ fcy 16 baud) 1))))) (actual-baud (/ fcy 16 (1+ brg))) (err (* 100 (- (/ actual-baud baud) 1)))) - (when (or (not view-below-percent) + (when (or (not view-below-percent) (< (abs err) view-below-percent)) (format t "~6D ~4D ~5,1F%~%" baud brg err)))))