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

PWM cannot set to 125khz frequency

Hi, 

I am using the nrf-52840 DK.

I modified the pwm_library to output 125khz frequency.

app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(125000L, NRF_GPIO_PIN_MAP(1,0) , NRF_GPIO_PIN_MAP(1,3));

I check the oscilloscope, the IC cannot generate such high frequency PWM.

Please advise how to set the PWM to generate 125kHz fequency.

Thanks

  • APP_PWM_INSTANCE(PWM1,1);                   // Create the instance "PWM1" using TIMER1.
    
    static volatile bool ready_flag;            // A flag indicating PWM status.
    
    void pwm_ready_callback(uint32_t pwm_id)    // PWM callback function
    {
        ready_flag = true;
    }
    
    int main(void)
    {
        ret_code_t err_code;
    
        /* 2-channel PWM, 125kHz, output on DK LED pins. */
        app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(8L, BSP_LED_0, BSP_LED_1);
    
        /* Switch the polarity of the second channel. */
        pwm1_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH;
    
        /* Initialize and enable PWM. */
        err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback);
        APP_ERROR_CHECK(err_code);
        app_pwm_enable(&PWM1);
        
        app_pwm_channel_duty_set(&PWM1, 0, 50);
        app_pwm_channel_duty_set(&PWM1, 1, 50);
    
        while (true)
        {        
        }
    
    }

Related