From c2f4aa8566e6d294e544084f286a5b06f070453e Mon Sep 17 00:00:00 2001 From: Roger Clark Date: Mon, 9 Jan 2017 21:17:28 +1100 Subject: [PATCH] Fixed tone() so it works is F_CPU is not 72Mhz --- STM32F1/cores/maple/tone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STM32F1/cores/maple/tone.cpp b/STM32F1/cores/maple/tone.cpp index 26aa676..965bfdd 100644 --- a/STM32F1/cores/maple/tone.cpp +++ b/STM32F1/cores/maple/tone.cpp @@ -147,7 +147,7 @@ void tone(uint32_t pin, uint32_t freq, uint32_t duration) { tone_timer->pause(); if(freq > 0 && duration >0 ){ - uint32_t count = 18000000/freq; // timer counts per half wave + uint32_t count = (F_CPU/4)/freq; // timer counts per half wave tone_ncount = tone_n = (count>>16)+1; // number of 16-bit count chunk tone_tcount = count/tone_ncount; // size of count chunk if(duration > 0) // number of half waves to be generated