This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

low_power_pwm with Frequency 4Khz

hello i am using the nrf52840.

how i can set the 4Khz frequency in low_power_pwm.

low_power_pwm_config_t have period parameters. which value i need to assign to generate the 4Khz Siganl.

before i used the APP_PWM which is much more easy but have some issue with nrf52840. because when i used the P1.08 pin then he is creathing some conflict with i2c. thats why i try to use the low_power_pwm and i also follow this Link

no matter if you help me to generate the 4Khz signal in Low power Pwm or to fix the issue with App_PWM.

in the APP_PWM i was generating the signal using this command which is working great.

/* 1-channel PWM, 4kHz, output on pin14. t = 1/f so i/4k= 250uS*/ app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(250, 14);

i also like to menstion that in APP_PWM i already declear the pin like this

#define Buzzer_Pin NRF_GPIO_PIN_MAP(1,8)

Parents
  • Hi,

    The low-power PWM library is for applications where you don't need high frequency or accuracy. 4KHz is close to limit of what the low-power PWM library is designed for, and you won’t actually get 4KHz without doing changes to the app_timer library(lowering the minimum value of the timeout_ticks defined in the library, this is not recommended). You also won’t get the full duty-cycle range using the low-power PWM library with this high frequency. So I would recommend using the PWM library(APP_PWM) or PWM driver with this frequency.

    There should not be any conflicts between APP_PWM and i2c. Are you getting some error when you try to use both? why do you think there is a conflict?

Reply
  • Hi,

    The low-power PWM library is for applications where you don't need high frequency or accuracy. 4KHz is close to limit of what the low-power PWM library is designed for, and you won’t actually get 4KHz without doing changes to the app_timer library(lowering the minimum value of the timeout_ticks defined in the library, this is not recommended). You also won’t get the full duty-cycle range using the low-power PWM library with this high frequency. So I would recommend using the PWM library(APP_PWM) or PWM driver with this frequency.

    There should not be any conflicts between APP_PWM and i2c. Are you getting some error when you try to use both? why do you think there is a conflict?

Children
No Data
Related