Getting a 'NRF_PWM1' undeclared (first use in this function); did you mean 'NRF_PWM0'?, error when building for a NRF52811 device

Hello, 

I am getting a strange error when I try to move any project from NRF52840 to NRF52811. I have started with the simple PWM library example, which builds successfully as is. but when I modify the project file (.emProject), this error shows up.  I followed this guide (https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Fnrf52811_user_guide.html) and was able to get the blinky app to compile correctly but it is not working with the PWM example. It seems like I am missing some compiler directive or something but I haven't been able to find it out.

Mike

  • Hello,

    The nRF52811 only has one PWM instance (PWM0), while the nRF52840 has 4 (PWM0, PWM1, PWM2 and PWM3).

    So if you are using the pwm_driver example from SDK\examples\peripheral\pwm_driver, you first need to strip it from all references using PWM1 and PWM2. Comment out the lines:

    static nrf_drv_pwm_t m_pwm1 = NRF_DRV_PWM_INSTANCE(1);
    static nrf_drv_pwm_t m_pwm2 = NRF_DRV_PWM_INSTANCE(2);

    And then remove all lines that are using m_pwm1 and m_pwm2 in the application.

    Best regards,

    Edvin

Related