Hi,
I'm processing data from 2 IMUs with the Teensy 3.6. I followed the best practices with interrupts and set it up like this:
The Problem I'm having is that some of my helper variables inside my sensor fusion functions are getting overwritten. I did some research and found this (see #4 and #5) about floating point values and interrupts:
https://community.arm.com/processor...ng-point-unit-on-the-arm-cortex--m4-processor
From what I understand I may need some extra stack space for when my processing function get interrupted by either IRS??
I tried another approach and moved the sensor-fusion stuff to the "if statement" for flag2 (Like the code below). When I do that, my calculations give me the proper results.
I can just stick to that second approach and be happy, I just want to understand why the other way does cause issues.
EDIT: Found out about something called "float re-entrancy" ... apparently interrupting functions like sin/cos can cause weird behaviour? Still don'understand this fully.
Best regards
I'm processing data from 2 IMUs with the Teensy 3.6. I followed the best practices with interrupts and set it up like this:
Code:
volatile int flag1, flag2;
void irs1() {
flag1 = 1;
}
void irs2() {
flag2 = 1;
}
loop() {
if (flag1) {
// read IMU per SPI, save to float data1[10] array
flag 1 = 0;
}
if (flag2) {
// read IMU per SPI, save to float data2[10] array
flag 2 = 0;
}
/* process in 1ms intervals */
if (micros() - last_timestamp > 1000) {
// sensor fusion calculations: use data1[10] and data2[10]
// takes about 10 micros to complete
}
}
The Problem I'm having is that some of my helper variables inside my sensor fusion functions are getting overwritten. I did some research and found this (see #4 and #5) about floating point values and interrupts:
https://community.arm.com/processor...ng-point-unit-on-the-arm-cortex--m4-processor
From what I understand I may need some extra stack space for when my processing function get interrupted by either IRS??
I tried another approach and moved the sensor-fusion stuff to the "if statement" for flag2 (Like the code below). When I do that, my calculations give me the proper results.
Code:
if (flag2) {
// read IMU per SPI, save to float data[10] array
flag 2 = 0;
/* process at rate of arrival of interrupt flags */
// sensor fusion calculations: use data1[10] and data2[10]
// takes about 10 micros to complete
}
I can just stick to that second approach and be happy, I just want to understand why the other way does cause issues.
EDIT: Found out about something called "float re-entrancy" ... apparently interrupting functions like sin/cos can cause weird behaviour? Still don'understand this fully.
Best regards
Last edited: