Skip to main content
taha_najmee
Associate II
October 29, 2012
Question

STM32F4Discovery VCP Problem

  • October 29, 2012
  • 3 replies
  • 951 views
Posted on October 29, 2012 at 01:55

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. 
    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    October 29, 2012
    Posted on October 29, 2012 at 02:37

    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.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    taha_najmee
    Associate II
    October 29, 2012
    Posted on October 29, 2012 at 18:42

    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. 

    Tesla DeLorean
    Guru
    October 29, 2012
    Posted on October 29, 2012 at 20:02

    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.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..