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)

  • 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?

  • thank you so i need APP_PWM. yes when i try to use the both i got error. when i init the APP_PWM immediately the value on the I2C Sensor giving me the garbage value.. these both work fine on nrf 52832 but not on nrf52840. may be i am using the P1.08 pin. this can be the issue. no idea. if you just try to run both nrf52840 then you will see.. and also try to use the P1.08 pin for pwm.... if you need code then i will send you...

  • Yes, please send me the code. It will be easier to try to reproduce the issue with the code you are using.

Related