This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

voice output using PWM

 Hello,

I'm trying to play voice using PWM in nRF51822.

I've already experienced this using other MCU before.

So. I'm trying.

Voice source data is 8bit / 8K / mono PCM sampling data.

I call below code according to 8KHz frequency.

I write the above PCM sampling data value to below level register.

The val register value is a fixed value of 50.

At the test level, I don't execute any other code, but only this code.

And the below code is used for buzzer playback now.

I don't know what's wrong.

Could anybody let me know what's wrong or some tip?

 Thanks and happy new year.

*****************************************************************************************

// for sound level

err_code = app_pwm_uninit(&PWM_BUZZER);
// NRF_LOG_RAW_INFO("pwm-buzzer uninit error : %d\r\n", err_code);
APP_ERROR_CHECK(err_code);

app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(level, BUZZER_PIN);
pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;

err_code = app_pwm_init(&PWM_BUZZER, &pwm1_cfg, NULL); // callback_pwmBuz);
// NRF_LOG_RAW_INFO("pwm-buzzer init error : %d\r\n", err_code);
APP_ERROR_CHECK(err_code);

app_pwm_enable(&PWM_BUZZER);
// NRF_LOG_RAW_INFO("pwm-buzzer enable\r\n");

// for sound strength
while(app_pwm_channel_duty_set(&PWM_BUZZER, 0, val) == NRF_ERROR_BUSY);

*****************************************************************************************

Parents Reply Children
No Data
Related