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

Timing behaviour with and without debugger connected.

We have a problem that we are struggling to solve. We have written an application for the Nordic Semiconductor nRF52832 which uses a proprietory radio protocol. This protocol is based on the concept of a time frame, during which a message is passed from a protocol master, received by the protocol slave, which then transmits a response which is in turn received by the originating master, during a fixed time frame. To achieve this, we program the hardware timers to run a software interrupt routine which sets the radio channel and triggers message transmission, and we use a combination of radio shortcuts and software interrupt handlers to process the radio message reception and schedule the reply. In order to gain a real-time understanding of the radio behaviour, we use dedicated GPIO channels which are driven either by PPI from radio events, or via software run from timer and radio interrupt handlers.

The core of the protocol which allows frame synchronization and message exchange has been implemented and shown to work (although there are a couple of corner case issues to resolve) reliably, while a debugger is attached to our IDE (we are using IAR Embedded Workbench for ARM). The problem we are experiencing is that when we detach the debugger logically (it is still physically connected to the target, but the IDE is not communicating with it), we can see that the GPIO channels allowing us to observe the radio operation significantly change their timing, and thus the protocol no longer operates.

So, with exactly the same hardware and software, the system timers, or PPI operation, or something, behaves very differently when a debugger is operational and when it is not, even though no trace is being collected from the target and no variables are being introspected while the target is running. Indeed, it is the case where the debugger is *dis*connected that seems to cause the problem. We are unaware of any mechanism by which this could happen, and of course are hampered in our investigations by the fact the it is only when we are unable to observe the system that it doesn't work correctly. A real Heisen-bug! Is there some interaction between the ARM trace macro cell and the Nordic bus infrastructure that we are not aware of, especially if debugging is not enabled?

  • Hi Dave, 

    Could you give more detail of the change in the timing ? If you can capture a logic analyzer trace showing how much off the timing it would be nice. 

    The only reason why enabling the debugger can cause the change in the timing I can think of is that the debugger when active will keep the CPU and the HFCLK running. 

    What do you use to keep the timing ? with the TIMER or with the RTC ? Please make sure that you initialized the clock source properly. 

    Do you put the CPU to sleep between the communication event ?

    You can test by disable the radio activity and only keep a timer running and check if the timer timeout drift off when you disable the debugger. 

Related