STM32F407VTG6 HardFault_Handler
There are a few things which come to mind that can cause such behaviour.

Somewhere in your code, you are activating an interrupt (may be in a driver call you're making) which occurs at that very moment, coincidentally. Yet, the interrupt has not been setup beforehand correctly (e.g. the entry in the IRQ table for that specific interrupt is missing) and it calls the hard fault handler as a default option
You have a pointer issue. Somewhere a pointer is used incorrectly and points to your stack. You are effectively modifying your stack and when it's time to jump back to the caller function, the return address in the stack points to an invalid location in memory.

What can you do:

Go through the driver code and check if there are any interrupts, check if they are setup correctly
Enable all warnings from your compilation &quot;-Wall&quot; and rebuild the complete project. Observe any warnings you may get. There may be one which indicates a problem with a pointer. It's always good to observe any warnings and correct them immediately - this will solve many errors which occur during runtime. Show us the warnings if you're unsure
Check if you have explicit casts in your code, those may obscure certain compiler warnings; I'm not saying they are not required but understand that you're telling the compiler that you're doing something (potentially harmful) on purpose