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

Default pin config = 31 is WRONG for nRF52840

in the sdk_config.h there are plenty of definitions, where "31" is used as a non-valid PIN value

This is destructive if you want to use p0.31

For example:

If one uses nrf_drv_pwm_init with {.driverConfig== NRF_DRV_PWM_DEFAULT_CONFIG} and changing only the pin you like, it will configure pin 0.31 as PWM !

You have to change the sdk_config.h default constants

Parents
  • Hi,

    For PWM you can use the NRF_DRV_PWM_PIN_NOT_USED define if you dont't want to use all the 4 channels in the PWM instance. With this method you don't need to change the sdk_config.h default vales. You can use NRF_DRV_PWM_PIN_NOT_USED like this:

    nrf_drv_pwm_config_t const config0 =
        {
            .output_pins =
            {
                BSP_LED_0 | NRF_DRV_PWM_PIN_INVERTED, // channel 0
                NRF_DRV_PWM_PIN_NOT_USED,             // channel 1
                NRF_DRV_PWM_PIN_NOT_USED,             // channel 2
                NRF_DRV_PWM_PIN_NOT_USED,             // channel 3
            },
            .irq_priority = APP_IRQ_PRIORITY_LOWEST,
            .base_clock   = NRF_PWM_CLK_125kHz,
            .count_mode   = NRF_PWM_MODE_UP,
            .top_value    = 25000,
            .load_mode    = NRF_PWM_LOAD_COMMON,
            .step_mode    = NRF_PWM_STEP_AUTO
        };

Reply
  • Hi,

    For PWM you can use the NRF_DRV_PWM_PIN_NOT_USED define if you dont't want to use all the 4 channels in the PWM instance. With this method you don't need to change the sdk_config.h default vales. You can use NRF_DRV_PWM_PIN_NOT_USED like this:

    nrf_drv_pwm_config_t const config0 =
        {
            .output_pins =
            {
                BSP_LED_0 | NRF_DRV_PWM_PIN_INVERTED, // channel 0
                NRF_DRV_PWM_PIN_NOT_USED,             // channel 1
                NRF_DRV_PWM_PIN_NOT_USED,             // channel 2
                NRF_DRV_PWM_PIN_NOT_USED,             // channel 3
            },
            .irq_priority = APP_IRQ_PRIORITY_LOWEST,
            .base_clock   = NRF_PWM_CLK_125kHz,
            .count_mode   = NRF_PWM_MODE_UP,
            .top_value    = 25000,
            .load_mode    = NRF_PWM_LOAD_COMMON,
            .step_mode    = NRF_PWM_STEP_AUTO
        };

Children
Related