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

s110 firmware working only in debug mode

I'm struggling to understand this strange issue. I have a firmware based on S110 SD on nRf51822-QFABA0, this firmware is still based on version 7.1.0. The application is based on a application timer firing every 1s. The timer handler performs some GPIO tasks and reads some sensor data over TWI. Then every 5 counts of the timer handler (i.e. every 5s) it starts advertising. The advertising is set to timeout after 1s with an interval of 2s so that it advertises only once but I have also tried different combinations of interval and timeout all giving the same result. In the main while loop I am using power_manage() to go to low power mode.

Now when running this in the debugger it works perfectly fine, no issue at all. Similarly if I program the board without resetting power it also works perfectly fine but as soon as I reset power the firmware starts behaving very strangely. The behavior seems to be very random, sometimes it works fine for 10s sometimes works for a few minutes and other times it doesn't work at all. Once it stops working no adverts are transmitted. This happens both when the programmer is still connected and when it is removed.

I have noticed a few things:

  • when running fine right after programming the power consumption is high, but this is not only because the programmer is still connected. The programmer itself seems to add around 1mA but when in this mode there is an additional 1mA or so of current draw, why is this higher?

  • when running fine, the 16Mhz crystal is active (checked with oscilloscope) for around 4ms during the actual advert transmission (so one every 5s) and off for the rest of the time, TWI queries run every 1s, the 32kHz crystal is continuously on. This is also the case for the brief period of normal operation after power has been cycled.

  • When the firmware hangs (after a power cycle), the 16Mhz crystal is permanently on - I assume the firmware goes into some kind of hardfault and stays there.

  • If I disable advertising and just run the timer calls, it works fine even after power reset, I can tell because I am toggling an LED in that case. So the issue seems to be somehow related to advertisements.

  • If I comment out the power_manage() function it also works fine after power reset and advertises properly but of course power consumption is high.

I see there are some other posts on the forum with similar issues but none of these seems to help so I'd really appreciate any comments that might help.

Thanks

Related