2023-12-04 04:48 AM
For producing 4KHz resonant frequency sound from a buzzer using 32KHz system clock, what should be the Prescaler value and Period(ARR)? Is there any rules for defining these values?
Solved! Go to Solution.
2023-12-04 05:07 AM
You could generate your 4kHz from the 32kHz with prescaler=0 (1 -1) and ARR=7 (8 -1). The product of PRE*ARR must be 8 in your case, although you can also use PRE=1 (2 -1) and ARR=3 (4 -1).
Does it answer your question?
Regards
/Peter
2023-12-04 05:07 AM
You could generate your 4kHz from the 32kHz with prescaler=0 (1 -1) and ARR=7 (8 -1). The product of PRE*ARR must be 8 in your case, although you can also use PRE=1 (2 -1) and ARR=3 (4 -1).
Does it answer your question?
Regards
/Peter
2023-12-04 05:22 AM
If you mean a 32768 Hz clock, you won't be able to get 4 kHz exactly, but you can get close (4096 Hz).
2023-12-04 05:37 AM
What about a 32MHz system clock and required frequency as 4KHz? Is there any rules in defining the PRE and ARR combination? I know that if the ARR register is 16bits, then the maximum value is 65535. anything else other than that
2023-12-04 06:01 AM
The same procedure applies: you need divide by 8000, so that any factors can be used (in the context of prime factorisation).