How are you generating the signal on PA6, and are you sure there is really something to see there?stan wrote: Fri Dec 18, 2020 4:42 pm it is compiling but not working I added LCD, in uno LCD it is alive in stm32 it is dead just displays 0.00 and do on respond to signal on PA6.
This is the sampling routine in Goertzel.cpp:
Code: Select all
/* Sample some test data. */
void Goertzel::sample(int sensorPin)
{
for (int index = 0; index < _N; index++)
{
testData[index] = analogRead(sensorPin);
}
}
If you can see the value changing, perhaps the sampling rate you have specified (8900) is just too different to what you are actually getting. This is the issue as mentioned already by Feluga and Fredfox. The sampling code simply spins around as fast as it can, and the rate is likely to be very different to what you get on a 16MHz Uno.
You could insert some code into Goertzel::sample() to see how long it takes, and from that work out the rate. It is going to also depend on the compiler and optimisation. Hopefully the actual rate you get is at least 10kHz to detect a 5kHz signal.
There is probably a better way to sample at a known rate, but may require drastic surgery to the code.