From fba977510c6345e6c44e0ead7a928d1cdf0c0ddc Mon Sep 17 00:00:00 2001 From: gutmet Date: Wed, 26 Oct 2022 11:19:39 +0200 Subject: [PATCH] add calculation note for freq table --- firmware/freq_table.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 firmware/freq_table.md diff --git a/firmware/freq_table.md b/firmware/freq_table.md new file mode 100644 index 0000000..d39b93b --- /dev/null +++ b/firmware/freq_table.md @@ -0,0 +1,17 @@ +Frequency table +============== + +calculation like: + +``` +rate = 8000000 / (3 * 64) +offset = 50 + +print "const uint16_t freq_table[] = {" + +for i in range(100): + n = int(440.0 / rate * 2 ** ((i - offset) / 12.0) * 2 ** 16 + 0.5) + if n < 0x10000 / 2: + print "/*0x%02x*/\t%d," % (i, n) +print "};" +```