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

Using the four PWM that are suppose to able to work with each hardware PWM!

I am able to use the 2 channel mode of each PWM giving me a total of six PWM that I can set individual duty cycle PWM!

I now find I need 8 PWM with individual duty cycles! Can anyone point me in the direction has sample code for using them?

 /**  Config is for PWM2 using both PWM channels on pins 24 and 25 with a frequency of 1/(20000uS) = 50Hz   */
     app_pwm_config_t pwm_config1 = {
          .pins              = {24, 25},
          .pin_polarity      = {APP_PWM_POLARITY_ACTIVE_HIGH, APP_PWM_POLARITY_ACTIVE_LOW},
          .num_of_channels   = 2,
          .period_us         = 20000L
      };

And this is were I write the values to the PWM!

while (app_pwm_channel_duty_set(&PWM1, 0, val1) == NRF_ERROR_BUSY); 
   while (app_pwm_channel_duty_set(&PWM1, 1,val2) == NRF_ERROR_BUSY);

Thanks!

Parents Reply
  • Hello,

    The app_pwm doesn't actually use the PWM hardware peripheral, but it uses timers together with PPI and the gpiote driver to toggle pins. The app_pwm module has some limitations, because it has to consider the amount of CC registers in a timer. The PPI example that is hard coded in the main.c file that I posted in my other link uses TIMER3, which has more CC registers, so it can fit more PWM signals. 

    The hardware PWM you can read about here. As you see this supports up to 12 PWM channels. There are 3 PWM hardware peripherals, and they each support up to 4 channels each. 

    BR,

    Edvin

Children
Related