2020-11-08 10:29 AM
STM32CubeIDE v1.4.2
STM32F4 v1.25.2
STM32F446RC
I generated my code and got this:
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
The HSE crystal is never turned on anywhere. Big bug.
I change this to:
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
//RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
And now my USB finally works. =)
HSE is configured in RCC as "Crystal/Ceramic Resonator". I have not added anything to the code. I can send you files if that would help.
Solved! Go to Solution.
2020-11-09 02:27 AM
Ok I found the problem. Inside my clock configuration "HSI" was selected and not "HSE". Not sure why STM32CubeIde wouldn't give a warning because the USB simply doesn't work with HSI selected.
2020-11-09 02:17 AM
I added the .ioc file. Should be now easy to reproduce this by simply running the code generation. The one GPIO PC3 I am using to light up an LED when the Error_Handler() is executed. Otherwise this is just USB CDC (Full Speed Device) + RCC HSE which is not generated correctly so I was seeing my LED light up and thought the crystal was working but no then I learned the STM32F4 has an internal one that was used instead which explained why the USB was not working :)
2020-11-09 02:27 AM
Ok I found the problem. Inside my clock configuration "HSI" was selected and not "HSE". Not sure why STM32CubeIde wouldn't give a warning because the USB simply doesn't work with HSI selected.