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

Debugging a APP_ERROR_CHECK

I am working on a project using a BLE Nano and Nordic sdk 8.1. I included the ble_flash.c, ble_error_log.c, and ble_debug_assert_handler.c files in my include path and c source files. I also added -DDEBUG to the flags. I then check if the app is failing using the APP_ERROR_CHECK(err_code); When I do this my program just stops running though and I don't get an error log or anything in the serial monitor and I don't see any stack trace saved on the device when I open it up. Are there any other steps I have to do or am I missing something? BTW I am compiling from terminal using a makefile.

  • line 839 in APP_ERROR_CHECK() and right above it is: err_code =app_pwm_init(&PWM1,&pwm1_cfg,NULL); So I'm guessing something is wrong with the PWM. What is PWM startm_error_code 8

  • As seen here, error code 8 is "NRF_ERROR_INVALID_STATE". Taking a look at app_pwm_init here, this is returned "If the timer/PWM is already in use or if initialization failed.".

  • Looks like this might be an old bug(this is the drawback when working with old SDKs). Try to add: PWM1.p_cb->state = NRF_DRV_STATE_UNINITIALIZED; before calling the init function:

    /* Initialize and enable PWM. */
    PWM1.p_cb->state = NRF_DRV_STATE_UNINITIALIZED;
    err_code = app_pwm_init(&PWM1,&pwm1_cfg,NULL);
    

    If this does not work, try to use a different timer when creating the PWM instance, e.g. timer 2: APP_PWM_INSTANCE(PWM1,2);

  • Alright I tried calling PWM1.p_cb->state = NRF_DRV_STATE_UNINITIALIZED before the app_pwm_init() but it didn't change the behavior.

  • I tried using timer2 but I got the following error: "In file included from ../../../../../../components/libraries/pwm/app_pwm.h:38:0, from ../../../main.c:40: ../../../../../../components/drivers_nrf/timer/nrf_drv_timer.h:48:31: error: 'TIMER2_INSTANCE_INDEX' undeclared here (not in a function) .instance_id = TIMER##id##INSTANCE_INDEX,
    ^ ../../../../../../components/libraries/pwm/app_pwm.h:50:50: note: in expansion of macro 'NRF_DRV_TIMER_INSTANCE' const nrf_drv_timer_t m_pwm
    ##name##_timer = NRF_DRV_TIMER_INSTANCE(num);
    ^ ../../../main.c:44:1: note: in expansion of macro 'APP_PWM_INSTANCE' APP_PWM_INSTANCE(PWM1,2); // Create the instance "PWM1" using TIMER2. ^ "

    Is there anything I have to do to initialize timer2?

1 2 3