I am writing the attitude estimation code for my drone, so I included the Eigen library to handle matrix operations. During debugging, I found that my program entered a hard fault while performing matrix operations with the Eigen library.
It shows that I enter a hard fault when reaching this line.
K_ = dh * P_next * dh_trans;
K_ is defined as
Eigen::Matrix<float, 9, 9> K_ {....}
dh is defined as
Eigen::Matrix<float, 9, 7> dh {....}
dh_trans is defined as
Eigen::Matrix<float, 7, 9> dh_trans = dh.transpose();
When the hard fault occurs, my LR data is 0xFFFFFFED and the PSP is 0x08019a88. In the STM32F401, this address is in the flash memory (0x8000 0000 - 0x0807 FFFF), and in my understanding, the PSP should not point to flash.
I dont know what make this happen,thanks for helping me!
Here are more info: The CFSR(Configurable fault status register) is 0x00000001.The manual for this section is as follows:CFSR MMFSR
The issue lies in my use of uC/OS. I called OSStatInit(), but if I call this function, I can only declare one task in main, and then declare other tasks within the first task. However, I have declared two tasks in main.