From e9ed4abac5eec7379e315d986a39c41d473e1c0e Mon Sep 17 00:00:00 2001 From: IOsetting Date: Thu, 27 Jan 2022 14:15:03 +0800 Subject: [PATCH] docs: dac demo comments --- demo/pwm/pwm_dac_voice/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/demo/pwm/pwm_dac_voice/main.c b/demo/pwm/pwm_dac_voice/main.c index 145f7cf..0185bf6 100644 --- a/demo/pwm/pwm_dac_voice/main.c +++ b/demo/pwm/pwm_dac_voice/main.c @@ -16,8 +16,9 @@ * Demo: DAC voice output simulation * Board: STC8H3K32 (types with flash size >= 32KB) * - * P1.0 -> Speaker + - * GND -> Speaker - + * P1.0 -> Speaker + // if speaker impedance is less than 8 ohms, + * wire a 5 ohm resistance between P1.0 and speaker + * GND -> Speaker - */ #include "fw_hal.h" #include "voice.h" @@ -42,6 +43,7 @@ void PWM_Init() PWMA_PWM1_SetPortState(HAL_State_ON); // Set PWM frequency to 16kHz, Fpwm = SYSCLK / (PWMx_PSCR + 1) / (PWMx_ARR + 1) + // You will hear obvious noise if PWM frequency is less than 12kHz PWMA_SetPrescaler(8); // PWM width = Period + 1 (side alignment), or AutoReloadPeriod * 2 (center alignment) PWMA_SetPeriod(0xFF);