Update calculator to handle goertzel

This commit is contained in:
cnlohr
2024-06-24 02:48:18 -07:00
parent 9f0cc2c50d
commit 2b75c51cd9
9 changed files with 171 additions and 96 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ TARGET_MCU:=CH32V203G6U6
TARGET_MCU_PACKAGE:=CH32V203G6U6
CH32V003FUN:=../ch32v003fun/ch32v003fun
EXTRA_CFLAGS:=-Wno-unused-function -I../../lib -I../ch32v203-fft/lib
EXTRA_CFLAGS:=-Wno-unused-function -I../../lib -I../lib
include ../ch32v003fun/ch32v003fun/ch32v003fun.mk
+1 -2
View File
@@ -68,7 +68,7 @@ SOFTWARE.
#include "ssd1306.h"
#define PWM_PERIOD (31-1) //For 27.0MHz, use 36MHz if quadrature -- It appears to be good for *244 in the table? WHY 26MHz???!?!!?
#define PWM_PERIOD (31-1)
#define ADC_BUFFSIZE 512
@@ -83,7 +83,6 @@ const int32_t g_goertzel_omega_per_sample = 1238618695; // 47/256 -> 27.01920 MH
const int32_t g_goertzel_coefficient = 870249096;
const int32_t g_goertzel_coefficient_s = 1963250500;
#define LOG_GOERTZEL_LIST 256
int32_t gertzellogs[LOG_GOERTZEL_LIST*2];
int gertzellogs_head;
+1
View File
@@ -13,6 +13,7 @@ int32_t g_goertzelp_store, g_goertzelp2_store;
int main()
{
//XXX XXX NOTE If you are computing the coefficients, you can plug the value in here.
// You can get this number from calculator.html. I've had better luck with "inverse goertzel" numbers.
g_goertzel_omega_per_sample = (47.0/256) * 3.1415926535*2.0*(1<<29);
g_goertzel_coefficient = 2 * cos( g_goertzel_omega_per_sample / (double)(1<<29) ) * (1<<30);
g_goertzel_coefficient_s = 2 * sin( g_goertzel_omega_per_sample / (double)(1<<29) ) * (1<<30);