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

Proper sequence to initialize PWM?

I'm having difficulty with using PWM library with softdevice. The app_pwm_init function returns

NRF_SUCCESS but call to app_pwm_enable does not generate an output.

//PWM sound generation
APP_PWM_INSTANCE(PWMpiezo,1);

void pwm_ready_callback(uint32_t pwm_id)    // PWM callback function
{

}

void UI_pwm_init()
{
    ret_code_t err_code;

    app_pwm_config_t piezo_config = APP_PWM_DEFAULT_CONFIG_1CH(250UL,PIEZO); //4KHz 
    // Initialize the PWM library
    err_code = app_pwm_init(&PWMpiezo,&piezo_config,pwm_ready_callback);
    if(err_code == NRF_SUCCESS)
    {
	app_pwm_enable(&PWMpiezo);
     }
}

Documentation doesn't detail where init should take place but an answer to a question here says it should be before the ble_stack_init. Are there other restrictions on where it should be done?

Or do I have an error in the code that I can't see? Thanks! Neil

Parents Reply Children
No Data
Related