Without the ST HAL, you’re on your own for establishing CPU clock speeds correctly as well as other settings that could impact stability. Any chance you’ve missed a setting, and now might be running the MCU outside its operational parameters? If you can put the repo on github I’d be happy to take a look.