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

Control 6 channel PWM at the same time which can modify duty-cycle by app_timer

Hi,

There have 4 PWM sample code (low_power_pwm, pwm_driver, pwm_library and pwr_mgmt) in SDK 15.2.

I my use case is "Control 6 PWM output with different duty-cycle and duty-cycle can modify by app_timer".

Which sample is suitable for this situation?

Thank you,

Chianglin

Parents
  • chianglin said:
    I am try to add a nrf timer into my original ble_app_uart project, but the system will crash when execute "ble_stack_init()" function.

    Add "DEBUG" to your preprocessor defines. One of your APP_ERROR_CHECK(err_code); receives an err_code != 0. this will tell you which one, and what value err_code has. What function returned the err_code != 0? and what is err_code?

  • Hi,

    Thank you for your quick answer.

    I had change nrf timer to timer-1, then the system will not crash anymore.

    Does it the correct solution?

    About the question "How can I control PWM to send some step, then stop PWM  output. (for example: 20 steps)?", would you please give my some idea?

    Thank you

  • I assume you meant TIMER0 to TIMER1? That would make sense, because the softdevice uses TIMER0, and you will probably get an error if you try to use that in addition to the softdevice. You will either get a softdevice assert, or you will get an err_code != NRF_SUCCESS passed onto an APP_ERROR_CHECK(err_code), which will stop your application.

    Regarding the 20 pulses:

    Do you use the PPI implementation, or the PWM driver or library?

    BR,

    Edvin

Reply
  • I assume you meant TIMER0 to TIMER1? That would make sense, because the softdevice uses TIMER0, and you will probably get an error if you try to use that in addition to the softdevice. You will either get a softdevice assert, or you will get an err_code != NRF_SUCCESS passed onto an APP_ERROR_CHECK(err_code), which will stop your application.

    Regarding the 20 pulses:

    Do you use the PPI implementation, or the PWM driver or library?

    BR,

    Edvin

Children
  • Hi Edvin,

    I can use output 20 pulse successful by using PPI implementation, but how can I do this job by PWM?

    Thank you,

    Chianglin

  • I still don't know whether you mean the PWM driver or PWM library.

    Assuming PWM driver:

    If you look in the pwm_driver example, e.g. in the demo3() function on line 276 in main.c, you will see that it first sets up what pins to use, the speed and some other setup-stuff. On line 296:

    (void)nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 3, NRF_DRV_PWM_FLAG_STOP);

    This is actually calling:

    uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * const p_instance,
                                      nrf_pwm_sequence_t const * p_sequence,
                                      uint16_t                   playback_count,
                                      uint32_t                   flags)

    As you can see, the 3rd input parameter is the playback count. You can play around with this to set the number of times your PWM sequence should play.

    BR,

    Edvin

Related