Re: [Flashforth-devel] Git(?), v5.0, and long division
Brought to you by:
oh2aun
From: Mikael N. <mik...@pp...> - 2014-03-05 18:58:51
|
Craig, Here is my take on calculating the spbrg value. It takes the CPU clock from Fcy and the baudrate and baudgenerator prescaler (16 or 64) is given as input. Not difficult at all. Just normal 16-bit Forth integer scaling stuff. $ffaf constant spbrg spbrg c@ . 18 ok<#,ram> : >spbrg ( double-baud brg-prescaler -- n ) >r #100 um/mod nip >r Fcy #40 um* r> um/mod nip r> / 1- ; 38400. 16 >spbrg . 18 ok<#,ram> |