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

nRF52840 Hard fault issue

Hi All,

I am working on the nRF52840 Zigbee protocol and I am using nRF5_SDK_for_Thread_and_Zigbee_v3.0.0_d310e71 SDK.

With the help of engineers and other stuff, I am able to design my end product using Zigbee and Alexa communication.

My product is about, It is a Zigbee based light controlling device which uses Alexa as a command sending device for controlling brightness and On/Off.

It is the last stage of production but while testing we have an encounter with the Hardfault issue. And enable to trace and yet no solution found also I had been touch with nordic engineers from the start of my project to till today but we are not able to fix this issue yet.

Here is my ticket - https://devzone.nordicsemi.com/support/234827

My project, I am using 1 as Input pin ZCD (Zero Cross Detection pin), 1 as Output pin Trigger pin (Trigger for turning On/Off ), and 2 timers (Timer 4 and Timer 0).

Workflow - The device is powered with AC voltage, When there is ZCD detection using Timer as duty cycle (i.e., brightness level), we pass timer values for 0msec to 10msec (i.e., 0 % to 100%). This we pass for both the Positive cycle and the Negative cycle of the MOSFET trigger.

The result - While testing this device after 6 to 8 hours it enters into the hard fault handler we tried to figure out the issue but still no success. And as per one of your engineer suggestions, may be cause for hard fault issue is Timer 0 which is configured as continuous as we are using disable an interrupt routine. And as per his suggestion, we have configured timer 0 as a one-shot timer. You can check the ticket for more details.

After his suggestion, configured Timer 0 (which I am using in my project as a one-shot) but its interrupt routine means timer 0's interrupt routine not executing. Then we tried with other timers like 1 but the device starts flickering. And If configure the timer as a continuous timer using "nrf_drv_timer_extended_compare()" instead of one-shot as done before then it works smoothly.

I am not able to figure out this Hardfault issue and Timer one-shot issue.

Attached are my code and schematic file. Kindly help me to solve this issue as early as possible. It is very urgent for me as we are in the last stage of production only due to this hard fault issue we are stuck here.

nRF_Dimmer XXX-00-CIR.PDF

I am attaching 2 code, wherein one(Zigbee_Dimmer-0.9.4) we have used continuous timer and we stuck in hard fault issue. And another one(Zigbee_Dimmer-0.9.6.1) is where we have configured timer as a one-shot timer as a solution for hard fault issues.

a)Zigbee_Dimmer-0.9.4

Zigbee_Dimmer-0.9.4.zip

b)Zigbee_Dimmer-0.9.6.1

Zigbee_Dimmer-0.9.6.1.zip

Please help me to solve this issue.

Thanks in advance.

Rohit R

  • Hi Susheel,

    The timer is still running keeping the HFCLK active. If you do not need the timer it is best practice to disable it. the callback is still only called once even if you DO NOT disable it, but i recommend you to disable the timer if you do not need to use it again for considerable amount of time.

    - Okay, I will disable it and check the result.

    - I will get back to you once I test all the suggested points.

    Thanks for the update

    Regards

    Rohit R

  • Hi Susheel,

    Sorry for the late reply,

    As per your suggestion, what i did is in 0.9.6.1 version firmware I have used nrf_drv_timer_disable(&Timer0) and kept timer 0 as one shot timer using nrf_drv_timer_compare().

    And I am able to execute the timer0's event handler, means statements inside handler function as explained in previous post.

    So I kept the dev-kit running with above configuration but after 4 hour it enters into hard fault handler. Below are the attached screen shot of the same.

    1st is when code enters into hard fault handler and 2nd is when I again run the code using step over command.

    Please check the CPU window and it's SP, LR, and register values and let me know based on this what could be the issue. Or how to figure out the problem.

     hard fault 2.zip

    Thanks and Regards

    Rohit R

  • Hi Susheel,

    There is one more bad news or facing the same problem.

    As I told in a previous post or my last ticket, I am developing another project and which also similar to the current device based on ZCD (Zero cross detection) and Timer using Zigbee to control bulb brightness.

    My first phase is developed using ZCD and Timer for controlling brightness it has been observed that in the new version of the device also I am facing a hard fault issue after 4/5 hours. After 4/5 hours fixed device stops responding.

    Attached in the hard fault screenshot.

    And I think for both my project ( both versions of devices) causing the same issue which results in hard fault after a few hours. But I am unable to trace back and slove it.

    It will be very helpful for me if you guide me to trace my issue. please let me know the steps or guide to trace the same.

    And, I have some question please help me with it.

    1) in sdk_config.h file,  #define TIMER0_ENABLED 1 like this I have done for timer 2 and timer 4 which I am using in my project.  And in same file I can see that #define NRFX_TIMER0_ENABLED 0 also present for all timers so do I need to enable this also?

    2) Instead of timer 0, I tried to configure timer 1 for 10msec but I am not able to configure it for 10msec.

    below is snippet which I followed to configure timer0, timer2 and timer4 as 10msec timer,

    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
        timer_cfg.frequency = 4; //set frequency 1MHz  
        err_code = nrf_drv_timer_init(&TIMER_1, &timer_cfg, timer1_event_handler);
        if (err_code != NRF_SUCCESS)
        {
            // handle error condition
        }

    If I follow same configuration for timer 1 then I am unable to configure it for 10msec. Can you please let me know what is the problem for timer 1 configuration or how to configure it for 10msec?

    Let me know your feedback.

    Thanks and Regards

    Rohit R

  • Hi Rohit

    I'm sorry about the late reply, but Susheel is out of office for the time being, so I've been tasked to look into this while he is away. I will get back to you regarding these stack pointer values as I'll have to ask internally for what exactly these points to, hopefully I'll get back to you tomorrow.

    As for the questions in your latest reply:

    1. You do not have to define both TIMER0_ENABLED and NRFX_TIMER0_ENABLED, as these defines are taken care of in apply_old_config.h and NRFX_TIMER0_ENABLED will be set equal to TIMER0_ENABLED in this case. The same goes for timers 2 and 4 as well.

    2. Timer 1 is not enabled by default in the light_bulb example, so it shouldn't be used for anything else as far as I know. What happens when you try to configure Timer1 as a 10ms timer, do you see some kind of error? Have you enabled TIMER1_ENABLED in sdk_config.h? Also, please make sure that Timer1 is not used anywhere else in your project.

    Best regards,

    Simon

  • Hi Simon,

    Thanks for the response,

    I'm sorry about the late reply, but Susheel is out of office for the time being, so I've been tasked to look into this while he is away. I will get back to you regarding these stack pointer values as I'll have to ask internally for what exactly these points to, hopefully I'll get back to you tomorrow.

    - Okay, please let me know

    2. Timer 1 is not enabled by default in the light_bulb example, so it shouldn't be used for anything else as far as I know. What happens when you try to configure Timer1 as a 10ms timer, do you see some kind of error? Have you enabled TIMER1_ENABLED in sdk_config.h? Also, please make sure that Timer1 is not used anywhere else in your project.

    - Ya, I have enabled in sdk_config.h file as done for timer 2 and timer 4. I have followed the same way as done for timer 2 and timer 4 to configure timer 1 but if I run the code, I should get interrupted for every 10msec but I am getting some random amount of time to interrupt example 5sec/10sec.

    - Then I thought let's configure the same timer (timer 1) for 5sec and check but there also the same it not running as expected.

    - I tried to search in code whether it is already used somewhere or not, but I could not found any relevant data regarding this. If you know then please let me know is it already used or not?

    Thanks and Regards

    Rohit R

Related