Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Need to "Erase All" before I can run project without crashing.

Hi all,

I'm working on a project in SDK 5 (V17.0.2) on a custom board using a raytac nrf52840 module. IDE is segger embedded studio with a J-Link interface to the hardware.

The project has been going for a while and the code has been in a reasonably stable state.

Just recently the project has gone into a "phase" where I cannot reload new code unless I first "Erase All" flash. This is a new situation, previously I could happily reload code and continue debugging.

Now, if I write new code (or even stop and restart without code changes) and try to run in debug mode without "Erase All", the code hangs in drv_rtc_init()  at NVIC_EnableIRQ(RTC1_IRQn)

I have 2 timers running under app_timer - nothing has really changed there between when it was working normally and now.

If anyone has any ideas, it would be much appreciated.

Regards,

Carl Kamper.

  • Hello,

    Where in drv_rtc_init() is it that the code hangs? In the call to NVIC_EnableIRQ() itself? Is this something that I can replicate using a DK? Do you see it in other examples using the RTC? 

    Are you using the watchdog timer?

    Best regards,

    Edvin

  • Thanks for your reply Edvin.

    Yes, It is the call to NVIC_EnableIRQ() where the code hangs. I'm not using a watchdog timer at the moment.

    I have traced the problem to a call to nrf_gpio_pin_set() which turns on a relay. Once the code progresses past this point, it cannot be restarted in the debugger without Erasing Flash.

    I don't know if the relay is creating some type of power disturbance (although it does have a back-emf diode on the coil).

    The problem is exceedingly strange and I will investigate further but for now I can work on the code.

    Regards,

    Carl.

  • Hi Edvin,

    I've just found some more information about the "Erase All" issue.

    I have used Port pin 1.09 as the relay control pin. This is a shared pin with TraceData3.

    I'm using SWO protocol for debug so the TraceData 1-3 shouldn't be in use but I don't really understand how to specify the TraceData pins to be in their alternate GPIO definitions.

    How do I ensure in my project that the TraceData 1-3 pins are set to their alternate GPIO use?

    Regards,

    Carl Kamper.

  • CarlK said:
    I'm not using a watchdog timer at the moment.

     Just to be clear. Did you at some point? The watchdog is a bit hard to kill, so is your chip erased since the watchdog was enabled (if it ever was)?

    Are you using a DK? Or can you try to use a DK? If so, please check out the section on trace debugging:

    https://infocenter.nordicsemi.com/topic/ug_nrf52840_dk/UG/dk/hw_debug_in_trace.html

     

    CarlK said:
    but I don't really understand how to specify the TraceData pins to be in their alternate GPIO definitions.

     I don't think you can do that, but I am not sure what the trace switch on the DK does, and much less how to modify this on the raytac module. I guess you have to check with the producers. Or alternatively, perhaps you can use another pin, if it isn't too much work to change (depends on how far in the PCB design you have come).

    Best regards,

    Edvin

  • So, to close the loop. I managed to get to the bottom of the problem & it wasn't software related at all.

    When spinning up a new board, I set my bench power supply to a reasonable current limit to stop possible destruction.

    At the current limit that I had chosen, and when the relay was operated, I'm guessing the voltage took a dive due to the current limit and corrupted something.

    Weird effect that became even weirder when I moved the relay control away from TraceData(3) and on to another pin .. at least the effect was more pronounced and led me to the realisation.

    Thanks for looking into the issue Edvin.

    Reagrds,

    Carl.

Related