(defpackage #:cluck
(:use #:cl)
- (:export
+ (:export
#:show-timers
#:show-8-bit-timers
#:show-16-bit-timers
(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)")
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)))
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)))))