5 years later, and I have the same problem with STM32F765 and STM32CubeIDE 1.15.1. Thanks for the work-around.I thought about clocking out 0xFF without Chip Select (NSS), but that seemed complicated.hal_spi code calls __HAL_SPI_DISABLE(hspi); itself...
I'm having the same issue with 1.15.1 Stm32CubeIDE on Windows 10 with code I'm trying to put into User Code sections in usbh_conf.c for STM32H745 code. No matter what I do, it keeps deleting my code when I re-generate the code.