Hello, everyone.
I learned about Bluetooth communication through the example of ble_app_uart. I learned about Bluetooth communication through the example of bl_app_uart. And I used the pwm_library to use the buzzer. There is no problem using the buzzer in the pwm_library. And we merged this into bl_app_uart. However, the buzzer operates in this code, but the BLE does not.
The following is a section on the PWM in the main().
#define buzzer_pin 25
APP_PWM_INSTANCE(PWM1,1); // Create the instance "PWM1" using TIMER1.
static volatile bool ready_flag; // A flag indicating PWM status.
void pwm_ready_callback(uint32_t pwm_id) // PWM callback function
{
ready_flag = true;
}
.
.
.
int main()
{
//PWM setting
ret_code_t err_code;`
app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(1500, buzzer_pin); //period_in_us(sound), pin
/* Switch the polarity of the second channel. */
pwm1_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH;
/* Initialize and enable PWM. */
err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback);
APP_ERROR_CHECK(err_code);
for(;;)
{
//PWM
ready_flag = false;
//wait for callback
while (app_pwm_channel_duty_set(&PWM1, 0, 10) == NRF_ERROR_BUSY); //p_instance, channel, duty cycle(%)
app_pwm_enable(&PWM1); //start pwm
}
}
Can I get a solution to this problem?
Thank you.