Dear Nordic,
I am running into an interesting side effect when I disable the app scheduler library from my program. I have been previously using the app scheduler to service all of my app timers, but I am now trying to reduce my dependency on this library in favor of traditional interrupts. I have an app_timer that samples an accelerometer at 500Hz and it works great as it is currently (with the scheduler) but when I disable the app scheduler I get a flood of FPU exceptions. There is a floating point operation that occurs in the interrupt but it is a single float multiplication. Below are the relevant functions and data structures involved in the interrupt. I have implemented a FPU exception handler interrupt according to the SDK example and log each error case.
I have done a couple of experiments that unfortunately did not help me understand the issue any better:
- wrapping the interrupt in a critical section did not help
- adding a flag to check if the interrupt was somehow interrupting itself showed that this is not the case. Similarly reducing speed of the interrupt did not solve the problem.
- simply removing the multiplication caused this issue to go away so I am pretty sure this interrupt is the problem
typedef union
{
int16_t i16bit[3];
uint8_t u8bit[6];
} axis3bit16_t;
static axis3bit16_t m_raw_acceleration;
static float acceleration_mg[3];
//NOTE: this is the interrupt called from an app_timer
void get_accel()
{
uint8_t reg;
/* Read output only if new xl value is available */
xl_flag_data_ready_get(&m_dev_ctx, ®);
if (reg) {
/* Read acceleration field data */
acceleration_raw_get(&m_dev_ctx, m_raw_acceleration.u8bit);
acceleration_mg[0] = from_fs16_to_mg(m_raw_acceleration.i16bit[0]);
acceleration_mg[1] = from_fs16_to_mg(m_raw_acceleration.i16bit[1]);
acceleration_mg[2] = from_fs16_to_mg(m_raw_acceleration.i16bit[2]);
}
}
//Conversion function from another file:
float_t from_fs16_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.488f;
}
