Aus RN-Wissen.de
Wechseln zu: Navigation, Suche
LiFePO4 Speicher Test

<script language="JavaScript">

var form;

var win_ubrr, fosc, baud; var row, ubrr, err;

function init() { form = document.forms["data"];

form.fosc.value="1.000000"; }

function round (x, n) { n = Math.pow (10, n); x = Math.round (n*x)/n; return x; }

function get_ubrr (baud, m) { var f = 1000000*fosc; var ubrra, bauda, erra; var ubrrb, baudb, errb;

ubrr = f/(m*baud)-1; ubrra = Math.floor (ubrr); ubrrb = Math.ceil (ubrr); bauda = f/(m*(ubrra+1)); baudb = f/(m*(ubrrb+1)); erra = bauda/baud-1; errb = baudb/baud-1;

if (Math.abs (erra) < Math.abs (errb)) { err = erra; ubrr = ubrra; } else { err = errb; ubrr = ubrrb; }

err = round (err*100, 1); if (ubrr >= 10) ubrr += "=0x" + ubrr.toString(16);

if (Math.abs (err) < 0.21) { err = ""+err+""; ubrr = ""+ubrr+""; } else if (Math.abs (err) > 10) { err = "–"; ubrr = err; } }

function get_row (baud) { var color = ((row & 1) == 0) ? "#ffffff" : "#f0f0ff"; var html = "<tr bgcolor=\""+color+"\">"; var baudstr = baud; var ubrr0, err0; var ubrr1, err1;

row++;

if (baud > 9600) { baudstr = "" + (baud / 1000) + "k"; }

if (baud > 250000) { baudstr = "" + (baud / 1000000) + "M"; }

get_ubrr (baud, 16); ubrr0 = ubrr; err0 = err;

get_ubrr (baud, 8); ubrr1 = ubrr; err1 = err;

html += "<td>"+baudstr+"</td>"; html += "<td align=\"center\">"+ubrr0+"</td>"; html += "<td align=\"center\">"+err0+"</td>"; html += "<td align=\"center\">"+ubrr1+"</td>"; html += "<td align=\"center\">"+err1+"</td>"; html += "</tr>\n";

return html; }

function write_ubrr_table () {

var html = "
";

row = 0;

html += "\n"; html += ""; html += "\n"; html += "\n"; html += ""; html += "\n";

html += get_row (2400); html += get_row (4800); html += get_row (9600); html += get_row (14400); html += get_row (19200); html += get_row (28800); html += get_row (38400); html += get_row (57600); html += get_row (76800); html += get_row (115200); html += get_row (230400); html += get_row (250000); html += get_row (500000); html += get_row (1000000);

html += "
Baud
Rate
(bps)
fosc = "+fosc+" MHz
U2X = 0U2X = 1
UBRRError (%)UBRRError (%)
\n";

// alert (html);

win_ubrr.document.writeln (html); }

function open_ubrr_window (val) { fosc = parseFloat (val);

if (win_ubrr) win_ubrr.close(); win_ubrr = window.open ("about:blank", "ubrr", "toolbar=no, menubar=no, width=400"); win_ubrr.focus(); win_ubrr.document.close(); // win_ubrr.document.open(); // win_ubrr.document.location.href = "about:blank";

var html = "<html>\n"; html += "<head>\n" html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"; html += "<meta name=\"Author\" content=\"Georg-Johann Lay\">\n"; html += "<title>ATMega8 Baudrate, fosc = "+fosc+" MHz</title>\n"; html += "</head>\n" win_ubrr.document.writeln (html);

html = "<body bgcolor=\"white\" text=\"black\">\n"; win_ubrr.document.writeln (html); write_ubrr_table (fosc, baud); html = "</body>\n"; html += "</html>\n"; win_ubrr.document.writeln (html); win_ubrr.document.close(); }

function write_freq_button (frq) { html = "<input type=submit onclick=\"open_ubrr_window("+frq+")\" SIZE=\"120\" VALUE=\" "+frq+" MHz \">";

document.writeln (html); }


</script>


LiFePO4 Speicher Test