2014-11-11 01:02 PM
Setup:
MDK-ARM uVison 5.10
Segger J-Link
Goal:
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.
#stm32f401 #hard-fault-exception2014-11-11 03:31 PM
Hard Faults at higher speeds are probably due to flash latency issues. Probably 2 wait states for 84 MHz.
Configuration looks to be set for 56 MHz operation. Unreliable USB operation, review external crystal circuit/characteristics.2014-11-11 04:44 PM
Thanks for your input. I have the configuration set for 56MHZ because that is the first setting greater than the USB required 48MHZ. I assume the core has to run faster than the USB required 48 MHZ. Is that correct?
I have attached the board 2 layer layout. The DP and DM lines go directly to the STM32F4 there are no pullup or in series resistors. Do I need them? FYI...I was running the full program originally with no USB on this board and everything seemed to work fine so I thought the crystal circuit was okay. Then I created this minimal program to try to troubleshoot the USB. The main 8 MHZ crystal Y2 runs pretty much directly to the STM32F4. It uses 18pF caps to ground per the datasheet for the crystal manufacturer. I will confirgure the MCO output and look at it on the scope to see how accurate it is. Maybe that will show me an issue. ________________ Attachments : Board_Layout.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0mM&d=%2Fa%2F0X0000000bdW%2FtXLSL6.nfEysi4yBx5jFdAfeL1Q1JDi3ONhrGgu9aTA&asPdf=false