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

nRF52 PWM frequency question

Hi,

By using the PWM exampl in SDK 0.9.2, I can generate a 1MHz PWM signal without problem. However, it seems that the function provided by SDK can just set upto 1MHz PWM?

I am using fillowing MACRO provided by SDK:

#define APP_PWM_DEFAULT_CONFIG_1CH(period_in_us, pin)                                  \
    {                                                                                  \
        .pins            = {pin, APP_PWM_NOPIN},                                       \
        .pin_polarity    = {APP_PWM_POLARITY_ACTIVE_LOW, APP_PWM_POLARITY_ACTIVE_LOW}, \
        .num_of_channels = 1,                                                          \
        .period_us       = period_in_us                                                \
    }

I then set APP_PWM_DEFAULT_CONFIG_1CH(1L, 8) and got 1MHz signal. If I need more higher frequency, say 4MHz, I need 0.25us in period_in_us field which is not allowed since it is uint32 type.

Is there any way to get more higher frequency than 1MHz?

Also, can this pwm library been use with SD? I can't get PWM out put if I try to config it in beacon example (set before the SD is init)

By the way, nRF52 do have PWM peripheral, why the example still using timer and PPI for PWM function? Is there any example to show how to use the real PWM peripheral?

Parents
  • Hi Nevill,

    By the way, nRF52 do have PWM peripheral, why the example still using timer and PPI for PWM function? Is there any example to show how to use the real PWM peripheral?

    This is because the SDK did not still implement the PWM hardware driver, it probably will come in the next release, I hope.

    Also, can this pwm library been use with SD? I can't get PWM out put if I try to config it in beacon example (set before the SD is init)

    Yes This library should work along side with SD, that was one of the main purpose of this driver.

    Is there any way to get more higher frequency than 1MHz?

    Its possible, You need to modify app_pwm macros and functions for this , so that they interpret the period_us values like you want.

    pwm_calculate_timer_frequency
    nrf_drv_timer_us_to_ticks
    

    I do not recommend this last step as I do not know the side effect of it. After changing those you are on your own.

    Good luck

Reply
  • Hi Nevill,

    By the way, nRF52 do have PWM peripheral, why the example still using timer and PPI for PWM function? Is there any example to show how to use the real PWM peripheral?

    This is because the SDK did not still implement the PWM hardware driver, it probably will come in the next release, I hope.

    Also, can this pwm library been use with SD? I can't get PWM out put if I try to config it in beacon example (set before the SD is init)

    Yes This library should work along side with SD, that was one of the main purpose of this driver.

    Is there any way to get more higher frequency than 1MHz?

    Its possible, You need to modify app_pwm macros and functions for this , so that they interpret the period_us values like you want.

    pwm_calculate_timer_frequency
    nrf_drv_timer_us_to_ticks
    

    I do not recommend this last step as I do not know the side effect of it. After changing those you are on your own.

    Good luck

Children
No Data
Related