MESC_Firmware
MESC_Firmware copied to clipboard
Hard fault handler error
Hello David I use the latest firmware to run at F405 , but I found that it occasionally or frequently enters : hard fault error. This error is difficult to locate. Do you have a solution for this part? And another question, how to use HFI or how to use HFI in low speed and switch to observer in high speed? When I turn on HFI, the motor can spin, but sometimes it rotated in CW, sometimes CCW, and the current is very high, the motor is very hot. I set hfi type 2, SL_sensor 3 . The above two questions: 1 : hard fault error, when start motor fast rotation potentiometer or RCPWM , and When put some load . 2: current is very high when use HFI function and the motor is very hot. Than you .
99% of the time hardfault is caused by uninitialised pointer or an error in pointer maths. I'd guess somewhere in the code the branching of the condition tree bypasses pointer calculations under certain conditions and this causes the error.
The easiest way to find this is to replicate it with the debugger plugged in under CUBEIDE, and then you can see the chain that led to the hardfault in the left hand debug menu.
This is not something that happens normally, there are a few places it can happen that I have experienced - if you are using different peripherals for communication without them set up totally correctly is one, and there is also possibility that your settings result in divide by zero if you have not initialised variables properly. Another may be that you have implemented field weakening current higher than the allowed current. Again, recreate it on CUBEIDE and look at the function call stack to find what caused it.
The F405 can be run without the RTOS but you would then need to ensure the defaults and parameters are all set as #defines. I think this is acheivable by just putting a while(1) ahead of the RTOS init.
The HFI should swap to observer at higher speeds. I think it is hard coded as being 4V of back EMF. I could parametise this, the intended use case was ebike where the typical battery is 40-80V so it swaps at ~5-10% speed.
The current use during HFI will always be higher, since the current is being injected... the heat may well be due to higher iron losses from the 10kHz AC current injected. If you intend long term operation in the near zero speed region, HFI is probably not a good option regardless of the implementation.... get an encoder...
I have similar issue with F411 device. I always get hard fault error right on startup. I think, it's caused by find_last_active_header().
I also tested older version for F411 from mid of 2023, but it shows same issue.
Unable to replicate with any hardware i have. F405 works fine, f411 is only loosely supported and i don't have one...