2012-10-28 05:55 PM
Hello,
I am trying to add VCP on STM32F4Discovery but have some issues which I am not able to figure out. When I add this command USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb); in main, it stops working. I tried to debug it using Keil and found out that it stops somewhere in the Reset_Handler code in startup_stm32f4xx.s file. It stops somewhere before going into the main() routine. Did anybody have similar kind of problem? I will really appreciate if someone can guide me through it.2012-10-28 06:37 PM
This code is not in that execution path. Take a look a system_stm32f4xx.c and SystemInit().
Turn off the ''run to main'' and step the debugger through the start up code. You could also use the STM3240G-EVAL project as the basis of your code, and make sure your settings (HSE, PLL, USB48) in system_stm32f4xx.c reflect the fact the discovery board uses an 8 MHz external crystal, not 25 MHz, and make sure the value is HSE_VALUE is correctly defined.2012-10-29 10:42 AM
Thanks for the reply ... My HSE Value is already 8MHz, but I didn't know that I have to change values for PLL and USB48. So those value should be 8MHz as well or something different?
Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP While debugging the code I observed that it executes the LDR R0, =__main but it goes somewhere after executing BX R0. I am not sure where it jumps to because the execution arrow is no where to be found on Keil after that particular instruction.2012-10-29 12:02 PM
Press the Stop button, or add some breakpoints.
__main is Keil's C runtime startup code, it should be clearing out the static allocations, and copying initialized data, prior to calling your main() function.