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
  • Hello,

    What happens if you try to add the last two PWMs the way that you already added the 6 that you currently have?

    BR,

    Edvin

  • This is what I changed it to!

     app_pwm_config_t pwm_config = {
              .pins              = {22, 23, 26},
              .pin_polarity      = {APP_PWM_POLARITY_ACTIVE_HIGH, APP_PWM_POLARITY_ACTIVE_LOW},
              .num_of_channels   = 3,
              .period_us         = 20000L
          };

    It locks up when it gets to.

    The program fails to responded. And when I try to disconnect from the Nordic UART program the Red connect led stays on solid red. If I comment out this line everything runs!

     while (app_pwm_channel_duty_set(&PWM1, 2, val);

Reply
  • This is what I changed it to!

     app_pwm_config_t pwm_config = {
              .pins              = {22, 23, 26},
              .pin_polarity      = {APP_PWM_POLARITY_ACTIVE_HIGH, APP_PWM_POLARITY_ACTIVE_LOW},
              .num_of_channels   = 3,
              .period_us         = 20000L
          };

    It locks up when it gets to.

    The program fails to responded. And when I try to disconnect from the Nordic UART program the Red connect led stays on solid red. If I comment out this line everything runs!

     while (app_pwm_channel_duty_set(&PWM1, 2, val);

Children
Related