pwm

how to set the duty cycle in pwm?

how to set the sequence values in pwm driver library?

  • A COUNTERTOP value smaller
    than the compare setting will result in a state where no PWM edges are generated this is true . but i am having doubt that COUNTERTOP value is used to set the duty cycle right?

  • Hi

    Did you figure out the problems of setting the right values?

    Essentially you need to set values between 0 - COUNTERTOP, and then the duty cycle is set as the value you set divided by COUNTERTOP. 

    As an example, if you have a COUNTERTOP value of 10000 and set a value of 2000 you should get a duty cycle of 20%. 

    venkatesha kj said:
    I would like to create 6 PWM signals with different duty cycles and the same frequency (20kHz) with pwm library is it possible?

    Yes, this is possible, but since each PWM controller can only control 4 outputs you need to enable two different PWM controllers to support 6 outputs. 

    Essentially you need to create one more instance type, and use an index other than 0, like this for instance:

    // Create a second PWM instance to allow 2 additional PWM channels (for a total of 6)
    static nrf_drv_pwm_t m_pwm1 = NRF_DRV_PWM_INSTANCE(1);

    Best regards
    Torbjørn

Related