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

Now need pwm_driver demo5 duty ratio, is there any way to 1/6 or 1/8?

How do you do Now need pwm_driver demo5 duty ratio, is there any way to 1/6 or 1/8?PWM and phase difference is 4 road? Ask for a few days, change seq_values [], but how to change?Try to success.

image description

Parents
  • You only need to declare the static nrf_pwm_values_individual_t seq_values_new[] once. Declare this at top of main.c, after the includes.

    And when you receive a new value over BLE, and want to use it to update the PWM duty cycle, you can do it like this:

    uint32_t vale = value_from_BLE;
    
    seq_values_new[0].channel_0 = (2000 | vale);
    
    nrf_pwm_values_t new_pwm_values; 
    
    new_pwm_values.p_individual = seq_values_new;
    
    nrf_drv_pwm_sequence_values_update(&m_pwm0,1,new_pwm_values);
    
Reply
  • You only need to declare the static nrf_pwm_values_individual_t seq_values_new[] once. Declare this at top of main.c, after the includes.

    And when you receive a new value over BLE, and want to use it to update the PWM duty cycle, you can do it like this:

    uint32_t vale = value_from_BLE;
    
    seq_values_new[0].channel_0 = (2000 | vale);
    
    nrf_pwm_values_t new_pwm_values; 
    
    new_pwm_values.p_individual = seq_values_new;
    
    nrf_drv_pwm_sequence_values_update(&m_pwm0,1,new_pwm_values);
    
Children
No Data
Related