Not worked properly on 168MHz
Hi! My case:
- DevBoard: STM32F4-DISCOVERY with STM32F407VG.
- Dtmf_CallBack called from TIM5, which tacted witch "TIM Clock = SyctemCoreClock / APB1_Clock".
- Decoder: Android application "DTMF Decoder" https://play.google.com/store/apps/details?id=com.encapsystems.dtmfd
Situation 1: PLLM=4, PLLN=72, PLLP=2, APB1_Prescaler = 2. SyctemCoreClock = 144MHz, APB1_Clock = 36MHz. TIM_Prescaler=17, TIM_Period=255. Decoding: Keys "1,2,3,4,5,6,7,8,9,*,0,#" decoded fine by first pressing, but "A,B,C,D" decoded not always - sometimes by first pressing, sometimes by second or third pressing.
Situation 2: PLLM=4, PLLN=144, PLLP=2, APB1_Prescaler = 4. SyctemCoreClock = 144MHz, APB1_Clock = 36MHz. TIM_Prescaler = 17, TIM_Period = 255. Decoding: same as in "Situation 1"
Situation 3: PLLM=4, PLLN=168, PLLP=2, APB1_Prescaler = 4. SyctemCoreClock = 168MHz, APB1_Clock = 42MHz. TIM_Prescaler=17, TIM_Period=255. Decoding: NOT
Situation 4: PLLM=4, PLLN=168, PLLP=2, APB1_Prescaler = 4. SyctemCoreClock = 168MHz, APB1_Clock = 42MHz. TIM_Prescaler = (17 * APB1_Clock) / 36 = 19.83 ~= 20, TIM_Period=255. Decoding: same as in "Situation 1"
Situation 5: PLLM=4, PLLN=180, PLLP=2, APB1_Prescaler = 4. SyctemCoreClock = 180MHz, APB1_Clock = 45MHz. TIM_Prescaler = (17 * APB1_Clock) / 36 = 21.25 ~= 21, TIM_Period=255. Decoding: Keys "2,3,A,5,6,B,8,9,C,0,#,D" decoded fine by first pressing, but "1,4,7,*" not decoded.
So, I think that with APB1_Clock=36MHz, real value of TIM_Prescaler must be not ceil 17, but 16.8-16.9.
In my projects, APB1_Clock may changed not only to 36MHz or 42MHz, but TIM_Prescaler must be only in ceil form, so I need to change dtmf_sine[], dtmf_code_high[] and dtmf_code_low[] accordingly to APB1_Clock.
So, my question: How you calculate dtmf_sine[], dtmf_code_high[], dtmf_code_low[] and TIM_Prescaler to APB1_Clock=36MHz?
Hi
I only test with cm3 and work fine.
I think your output have a problem. how you filter your output?
Hi! Output by Waveshare Analog Test Board (SKU: 3972), which use LM386.
I record signals by keys 1/5/9/D in Audacity and select "Analyze/Plot spectrum".
- variant A: SystemCoreClock=72Mhz, APB1_Clock=36MHz, TIM_Prescaler=17
- variant B: SystemCoreClock=144Mhz, APB1_Clock=36MHz, TIM_Prescaler=17
- variant C: SystemCoreClock=168Mhz, APB1_Clock=42MHz, TIM_Prescaler=20
Key | _ Etalon _ | ____ A ___ | ____ B ___ | ____ C ___ _ 1 | 1209 + 697 | 1208 + 696 | 1206 + 749 | 1206 + 701 _ 5 | 1336 + 770 | 1326 + 763 | 1325 + 772 | 1326 + 767 _ 9 | 1477 + 852 | 1468 + 845 | 1468 + 787 | 1467 + 780 _ D | 1633 + 941 | 1635 + 927 | 1636 + 928 | 1635 + 929
So, in "non 72 MHz" clocks, 3-rd low-frequency (etalon is 852 Hz) has more than 8% error:
- variant B: abs(100% - (852Hz * 100%) / 787Hz) = 9.23 (%);
- variant C: abs(100% - (852Hz * 100%) / 780Hz) = 8.26 (%).
But android app "DTMF Decoder" decode signals fine in all those 3 variants.
I thinked, that this error may be corrected by modified dtmf_code_low[], so modify dtmf_code_low[]:
- from {0, 46, 50, 56, 61}
- to {0, 46, 50, 57, 61}
and all signal was fine and decoded from first try, so I can decrease SendingTime!
But, I don't understand what I really do.
So, my questions:
- how you calculate dtmf_code_high[] and dtmf_code_low[]?
- how you calculate TIM_Prescaler (why 17 for 36MHz clock)?
I dont calulate. I use that value from other library