AnsweredAssumed Answered

STM32F401 Hard Fault with USB FS Device CDC mode

Question asked by hamilton.michael on Nov 11, 2014
Latest reply on Nov 12, 2014 by hamilton.michael


MDK-ARM uVison 5.10

Segger J-Link


Develop a prototype with USB virtual comm port.

What Works

I used the latest STM32CUBEMX to generate startup code for the STM32F401C-DISCO which contains a STM32F401VCT6 chip. The code is very basic with only the USB FS selected in CDC mode. In the main function, I am sending a simple message of “1234” every 2 seconds. This works as expected. I did have to increase the heap to 0x400 from 0x200 for windows 7 to recognize the port with no errors.

What Does Not Work

My prototype uses a STM32F401RCT6 (similar chip just 64 pins instead of 100 pins). I have attached the STM32CUBEMX project file and the only files that have been modified from the originally generated STM32CUBEMX project as well as a few oscilloscope pictures of DM and DP while the board is operating. There is a small amount of ringing which is probably due to the way that the probes / ground are connected to the board. The images look similar to the STM32F401C-DISCO board.

The code seems to run some of the time where other times I get a hard fault. When the code does run, my windows 7 machine recognizes the comm port, but when I monitor the virtual comm port with SerialMon (as well as others) I get no output. When I step through the program to this line:

result = USBD_CDC_TransmitPacket(hUsbDevice_0); I get a busy result.

I have also attached the different fault reports that I have gotten.

What Else Have I Tried

I tried different clock configurations. If the main clock is 42MHZ I don’t get the hard fault, but I still don’t get any serial output as described above. If the main clock is 84 MHZ I always get hard faults and the code never runs. Seems like the issue gets worse with increasing clock rates.

One thing I noticed, is the STM32CUBEMX project shows a yellow exclamation mark next to TIM1 in the project for the STM32F401RCT6 as shown in the attached screenshot. This is not shown in the STM32F401C-DISCO project. Both projects are configured the same except for the different chips being used.