cancel
Showing results for 
Search instead for 
Did you mean: 

STM3240G-EVAL USB-HS code don´t work

chmielewski
Associate II
Posted on January 03, 2014 at 08:17

hi,

maybe someone can help me. I want test the USB-HS on my board and take the example code from the ST Homepage. After the elimination of all compiler errors and declartion of the defined Symbols, the code stops in the startup_stm32f4xx.c file, at this function

static void Default_Handler(void)

{

    /* Go into an infinite loop. */

    while (1)

    {

    }

}

 

I work with coocox. Can someone help me with this problem or does anyone have the code for the USB-HS and can share with me?

My compiler control string is:

-mcpu=cortex-m4; -mthumb; -Wall; -ffunction-sections; -g; -O0; -DSTM32F407IG; -DSTM32F4XX; -DUSE_STDPERIPH_DRIVER; -D__ASSEMBLY__; -DUSE_USB_OTG_HS; -I.;

The code you find in the attachment.

Thanks
15 REPLIES 15
chmielewski
Associate II
Posted on January 06, 2014 at 16:14

hi,

first I want a correct connection to the PC, later I can change the code as I would like it.

The problem with the /* Go into an infinite loop. */ still exists   :\

Posted on January 06, 2014 at 16:23

Then figure out why you end up in the Hard Fault handler!

The processor creates a stack context, and system registers that can point you at the failing code. Examining this with current register settings can help understand the reason it got there.

Especially with

stupid

tools like CooCox which breaks the CMSIS, you'll want to pay specific attention to when/if SystemInit() is called. The the FPU is enabled, and the stack is adequate.

Classic reasons you might Hard Fault, reads/writes to the wrong memory, lack of require IRQ Handlers, too small or corrupted stack, linking with 32-bit ARM library code.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chmielewski
Associate II
Posted on January 06, 2014 at 16:59

one step further.

I change the code in the usb_bsp.c from the USB_OTG_BSP_uDelay into

void USB_OTG_BSP_uDelay (const uint32_t usec)

{

//#ifdef USE_ACCURATE_TIME

//  BSP_Delay(usec,TIM_USEC_DELAY);

//#else

  __IO uint32_t count = 0;

  const uint32_t utime = (120 * usec / 7);

  do

  {

    if ( ++count > utime )

    {

      return ;

    }

  }

  while (1);

//#endif

}

and the 'USB_OTG_BSP_mDelay' into

void USB_OTG_BSP_mDelay (const uint32_t msec)

{

//#ifdef USE_ACCURATE_TIME

//  BSP_Delay(msec,TIM_MSEC_DELAY);

//#else

  USB_OTG_BSP_uDelay(msec * 1000);

//#endif

}

and now it doesn´t go into the infinite loop. But the PC is still not find the connection. Only a unknown device :\

chen
Associate II
Posted on January 06, 2014 at 17:16

Hi

Silly question - do you have the VCP port driver installed on the PC?

''But the PC is still not find the connection. Only a unknown device''

Check the clock configuration! THe USB peripheral is VERY clock sensitive.

The USB peripheral MUST be clocked from a relatively accurate 48MHz - this

can be derived from the system clock but it must be relatively accurate.

chmielewski
Associate II
Posted on January 07, 2014 at 08:03

hi,

the VCP driver are installed.

Today I check the clock. The error

is

probably only a

trifle

chmielewski
Associate II
Posted on January 07, 2014 at 14:12

it works.

I forget to include the extern uint32_t USBD_OTG_ISR_Handler.

if

anyone is interested

, here is the

code

________________

Attachments :

USB-HS2.ZIP : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0v4&d=%2Fa%2F0X0000000bfb%2FOtEU.8eCHv59gfjDnU8yD1YY.FQ6q2fyWKQ.ZUUjtgo&asPdf=false