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 again Rohit

    I'm sorry, but it's taking more time than expected finding these stack pointer values than anticipated. Can you try editing the HardFault_process() function to process logs instead of rebooting. Replacing line 56-60 in hardfault_implementation.c to the following should do the trick, assuming that you have enabled logging in your application. Can you upload the log information processed here so we can take a look?

    __WEAK void HardFault_process(HardFault_stack_t * p_stack)
    {
        // Restart the system by default
        //NVIC_SystemReset();
        while (true)
        {
          NRF_LOG_PROCESS();
        }
    }

    As for the TIMER1 issue, I don't see any reason that this should behave different to the other timers. The only place it is mentioned in your project (0.9.6.1) where the others aren't is at line 100 in zb_nrf52840_timer.c, what are you using it for there? Are you able to see this behavior on more than one board? I tested Timer1 on a DK on my side, and I can't see any deviation when setting it to trig every 10 ms.

    Best regards,

    Simon

  • Hi Simon,

    Sorry for the late reply,

    Can you try editing the HardFault_process() function to process logs instead of rebooting. Replacing line 56-60 in hardfault_implementation.c to the following should do the trick, assuming that you have enabled logging in your application. Can you upload the log information processed here so we can take a look?

    - I have disabled the log because I am using P0_6 and P0_8 in my project, one as input and another one as output. I need to enable another UART pins and check the logs. Can you please share how to enable other pins as UART pin and test it.

    As for the TIMER1 issue, I don't see any reason that this should behave different to the other timers. The only place it is mentioned in your project (0.9.6.1) where the others aren't is at line 100 in zb_nrf52840_timer.c, what are you using it for there?

    - I did not understand it clearly.

    Are you able to see this behavior on more than one board? I tested Timer1 on a DK on my side, and I can't see any deviation when setting it to trig every 10 ms.

    - I have 3 boards and all are new but I am getting the same result. If I enable it for 10msec or either in 1sec also timer 1 not giving me the expected result.

    - If you have that code where timer 1 is enabled as 10msec in Zigbee light _bulb code then please share it I will compare it in my code.

    Thanks and Regards

    Rohit R

  • Hi Rohit

    1. You can do this by setting the NRF_LOG_BACKEND_UART_TX_PIN to a GPIO that is free in your project (I see that you have already set P0.10 as the TX pin in your project. This pin is reserved for the NFC antenna, so I suggest using another one, or set CONFIG_NFCT_PINS_AS_GPIOS  in your preprocessor definitions to use this pin as a regular GPIO. You also have to set NRF_LOG_BACKEND_UART_ENABLED to 1 in the sdk_config.h.

    2. What is TIMER1 used for in line 100 in the zb_nrf52840_timer.c file in your project?

    3. Thank you for clarifying.

    Best regards,

    Simon

  • Hi Simon,

    Thank you for the feedback,

    1. You can do this by setting the NRF_LOG_BACKEND_UART_TX_PIN to a GPIO that is free in your project (I see that you have already set P0.10 as the TX pin in your project. This pin is reserved for the NFC antenna, so I suggest using another one, or set CONFIG_NFCT_PINS_AS_GPIOS  in your preprocessor definitions to use this pin as a regular GPIO. You also have to set NRF_LOG_BACKEND_UART_ENABLED to 1 in the sdk_config.h.

    - Okay, I will follow this step and get back to you

    What is TIMER1 used for in line 100 in the zb_nrf52840_timer.c file in your project?

    - Sorry, but I do not know, It is already there I guess and I have not checked these files previously or not even edited. Maybe it by default in  SDK's light_bulb example and editing in main.c file other than that no other files where edited.

    Thanks and Regards

    Rohit R

  • Rohit Rajapure said:
    It is already there I guess

     Indeed, you're right, this is part of the Zigbee stack it seems, sorry about that! The Zigbee stack uses Timer1 already in nRF examples for timing beacon intervals, which explains why you're not able to use it like the other timers.

    Best regards,

    Simon

Related