nRF52840 NCS PWM interrupt error

change pwm_handler  to NULL is OK.

How to solve this problem?

Parents
  • Hello, 
    Sorry for the delayed answer. What application are you working on? Can you provide more details for me to replicate?

    -Øyvind

  • Thanks for providing that information. I'm able to replicate the issue. 

    ** Booting Zephyr OS build v3.0.99-ncs1  ***<\r><\n>
    [00:00:00.254,791] <27>[0m<inf> main: Found device pwmleds<27>[0m<\r><\n>
    [00:00:00.254,791] <27>[0m<inf> main: Testing LED 0 - no label<27>[0m<\r><\n>
    [00:00:00.254,821] <27>[0m<inf> main:   Turned on<27>[0m<\r><\n>
    [00:00:01.254,943] <27>[0m<inf> main:   Turned off<27>[0m<\r><\n>
    [00:00:02.255,065] <27>[0m<inf> main:   Increasing brightness grad[00:00:02.265,197] <27>[1;31m<err> os: >>> ZEPHYR FATAL ERROR 1: Unhandled interrupt on CPU 0<27>[0m<\r><\n>
    [00:00:02.265,228] <27>[1;31m<err> os: Current thread: 0x20000730 (unknown)<27>[0m<\r><\n>
    [00:00:02.519,714] <27>[1;31m<err> fatal_error: Resetting system<27>[0m<\r><\n>
    

    Will need some time to find a solution.

    Edit: Please note. From modules\hal\nordic\nrfx\drivers\include\nrfx_pwm.h

     * @brief Function for initializing the PWM driver.
     *
     * @param[in] p_instance Pointer to the driver instance structure.
     * @param[in] p_config   Pointer to the structure with the initial configuration.
     * @param[in] handler    Event handler provided by the user. If NULL is passed
     *                       instead, event notifications are not done and PWM
     *                       interrupts are disabled.
     * @param[in] p_context  Context passed to the event handler.
     *
     * @retval NRFX_SUCCESS             Initialization was successful.
     * @retval NRFX_ERROR_INVALID_STATE The driver was already initialized.
     */
    nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const *        p_instance,
                             nrfx_pwm_config_t const * p_config,
                             nrfx_pwm_handler_t        handler,
                             void *                    p_context);

    -Øyvind

  • Ok, so the LED PWM sample you are trying to use, is using Zephyr's PWM drivers. Adding nrfx drivers into this makes the project more confusing. 

    But to fix the issue with error you need to add the following.

    In zephyr\samples\drivers\led_pwm\prj.conf add:

    CONFIG_NRFX_PWM0=y

    Then on the top of your zephyr\samples\drivers\led_pwm\src\main.c add:

    #include "nrfx_pwm.h"

    In the main function (void main(void)) add IQR_CONNECT

    IRQ_CONNECT(PWM0_IRQn,5, nrfx_isr, nrfx_pwm_0_irq_handler, 0);

    This should allow you to change the handler of pwm_nrfx_init() in zephyr\drivers\pwm\pwm_nrfx.c.

    Please note that we encourage users to use e.g. Hello World sample and adding the correct nrfx calls directly. You can use the nrfx sample zephyr\samples\boards\nrf\nrfx\ as a starting point. 


    The Common Application Framework LED module might also be an alternative. This uses the Zephyr PWM drivers. Located under nrf\subsys\caf

Reply
  • Ok, so the LED PWM sample you are trying to use, is using Zephyr's PWM drivers. Adding nrfx drivers into this makes the project more confusing. 

    But to fix the issue with error you need to add the following.

    In zephyr\samples\drivers\led_pwm\prj.conf add:

    CONFIG_NRFX_PWM0=y

    Then on the top of your zephyr\samples\drivers\led_pwm\src\main.c add:

    #include "nrfx_pwm.h"

    In the main function (void main(void)) add IQR_CONNECT

    IRQ_CONNECT(PWM0_IRQn,5, nrfx_isr, nrfx_pwm_0_irq_handler, 0);

    This should allow you to change the handler of pwm_nrfx_init() in zephyr\drivers\pwm\pwm_nrfx.c.

    Please note that we encourage users to use e.g. Hello World sample and adding the correct nrfx calls directly. You can use the nrfx sample zephyr\samples\boards\nrf\nrfx\ as a starting point. 


    The Common Application Framework LED module might also be an alternative. This uses the Zephyr PWM drivers. Located under nrf\subsys\caf

Children
No Data
Related