Skip to content

Commit c2f4aa8

Browse files
Fixed tone() so it works is F_CPU is not 72Mhz
1 parent 7dcbbc8 commit c2f4aa8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

STM32F1/cores/maple/tone.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void tone(uint32_t pin, uint32_t freq, uint32_t duration) {
147147
tone_timer->pause();
148148

149149
if(freq > 0 && duration >0 ){
150-
uint32_t count = 18000000/freq; // timer counts per half wave
150+
uint32_t count = (F_CPU/4)/freq; // timer counts per half wave
151151
tone_ncount = tone_n = (count>>16)+1; // number of 16-bit count chunk
152152
tone_tcount = count/tone_ncount; // size of count chunk
153153
if(duration > 0) // number of half waves to be generated

0 commit comments

Comments
 (0)