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

pwm hardware individual loading mode nrf52

Please can anyone help me on how to use(program) PWM hardware with individual loading mode? My goal is to control 12 LEDs individually with different duty cycles and playbacks using pwm hardware which has 12 outputs to make a kind of led chaser.

Thanks in advance

Parents
  • @Akshaey: Have you tried to play with the pwm_driver example in the SDK the demo 1 example ? We have 3 PWM instance (PWM0, PWM1, PWM2) and each has 4 channels. In these 4 channel, they will have the same frequency, you can control duty cycle for each of them.

  • thanks for your reply,

    i have used the following method to vary pwm in 4 channels-

    the code is as follows-
    
    
       static nrf_pwm_values_individual_t  /*const*/ seq_values[] =
        {
          
    
      { 0, 5000, 5000, 5000 },
       { 250, 4750, 5000, 5000 },
       { 500, 4500, 5000, 5000},
    	 { 750, 4250, 5000, 5000 },
    	 { 1000, 4000, 5000, 5000 }
    
     };
        nrf_pwm_sequence_t const seq =
        {
            .values.p_individual = seq_values,
            .length              = NRF_PWM_VALUES_LENGTH(seq_values),
            .repeats             = 40,
            .end_delay           = 0
        };
    
        nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);
    

    it works but is it the correct method? Also can you help me as how can i use software pwm along with this program of hardware pwm? when i copy the code directly from pwm_library, it gives an error.

    thanks

Reply
  • thanks for your reply,

    i have used the following method to vary pwm in 4 channels-

    the code is as follows-
    
    
       static nrf_pwm_values_individual_t  /*const*/ seq_values[] =
        {
          
    
      { 0, 5000, 5000, 5000 },
       { 250, 4750, 5000, 5000 },
       { 500, 4500, 5000, 5000},
    	 { 750, 4250, 5000, 5000 },
    	 { 1000, 4000, 5000, 5000 }
    
     };
        nrf_pwm_sequence_t const seq =
        {
            .values.p_individual = seq_values,
            .length              = NRF_PWM_VALUES_LENGTH(seq_values),
            .repeats             = 40,
            .end_delay           = 0
        };
    
        nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);
    

    it works but is it the correct method? Also can you help me as how can i use software pwm along with this program of hardware pwm? when i copy the code directly from pwm_library, it gives an error.

    thanks

Children
No Data
Related