I'm getting a hardfault on some float operations that I wasn't getting before I upgraded to SDK 6.0.0 and SD 7.0.0. At least, I wasn't getting them at all before that and now I am, but not consistently.
I have a logging macro that writes timestamps to a log variable. I figure out the number of ticks elapsed since a given 'zeroing' of the timestamps and then get from ticks to seconds like this:
uint32_t ticks_to;
uint32_t err_code = app_timer_cnt_get(&ticks_to);
APP_ERROR_CHECK(err_code);
uint32_t ticks_elapsed;
err_code = app_timer_cnt_diff_compute(ticks_to, m_log_timer_zero, &ticks_elapsed);
APP_ERROR_CHECK(err_code);
float seconds_elapsed = (float)ticks_elapsed / (32 * 1000);
It's the last line that I get the hardfault on. I've seen a backtrace a bit like this, but with the above macro call at the bottom.
0x000161da in HardFault_Handler ()
(gdb) bt
#0 0x000161da in HardFault_Handler ()
#1 <signal handler called>
#2 0xfffffffe in ?? ()
#3 0x0003880c in _dtoa_r ()
#4 0x8000f7aa in ?? ()
#5 0x8000f7aa in ?? ()
The hardfault disappears if I hard code the seconds_elapsed value like this:
float seconds_elapsed = 1.0f;
It seems strange that SDK 6 would have had any affect on this but it's about all I can think of that's changed since this was working.
[EDIT]
This is still a problem now that I'm on SDK 8.1.0 so I think the SDK has nothing to do with it. I found this about it: