Is there a way to re-initialize low power PWM

I'm using three low power PWM instances driving three separate IO pins open an nRF 52810 and need to be able to re-configure each of the channels on the fly to select opposite polarity.  Unlike PWM duty cycle, I see no function that allows this.  The polarity of the output is established via a structure that is passed to the low_power_pwm_init function.  Attempts to re-init the PWM instance result in an error as is stated in the SDK description for Low Power PWM.  In my case the actual timing of the switch from one polarity to the other is not critical.  It can be sloppy.  So what is the best way to go about this?  Is there a way to un-initialize the PWM channel and then re-initialize it with the opposite polarity?

Parents
  • Hi,

    There does not seem to be an API for that.

    Some alternatives:

    1) Try creating a function for that library that just changes the polarity on the fly:

    ret_code_t low_power_pwm_set_polarity(low_power_pwm_t * p_pwm_instance, bool polarity)
    {
    
        p_pwm_instance->active_high = polarity;
    
        return NRF_SUCCESS;
    }


    2) Maybe you can have 2 instances, only difference is the polarity. And use low_power_pwm_stop() on the first instance, and then low_power_pwm_start() on the other when you want to change polarity.

Reply
  • Hi,

    There does not seem to be an API for that.

    Some alternatives:

    1) Try creating a function for that library that just changes the polarity on the fly:

    ret_code_t low_power_pwm_set_polarity(low_power_pwm_t * p_pwm_instance, bool polarity)
    {
    
        p_pwm_instance->active_high = polarity;
    
        return NRF_SUCCESS;
    }


    2) Maybe you can have 2 instances, only difference is the polarity. And use low_power_pwm_stop() on the first instance, and then low_power_pwm_start() on the other when you want to change polarity.

Children
No Data
Related