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
chen
Associate II
Posted on January 03, 2014 at 12:02

Hi

Oh dear - where do we start with helping you!

''I want test the USB-HS on my board and take the example code from the ST Homepage.''

Which example?

Do you mean the example for the STM3240G Eval board (as described in UM1492)?

 

What exactly are you trying to do?

Are yo trying to test the USB host (plug in USB memory stick) or

trying to test USB HIS/joystick example from the example project

or something else?

''the code stops in the startup_stm32f4xx.c file, at this function static void Default_Handler(void)

{

    /* Go into an infinite loop. */

    while (1)

    {

    }

}''

No, the code has not stopped - it is doing what it says - an infinite loop.

The 'default Handler' is an Interrupt Service Routine(ISR). It is probably used for nearly all the interrupts (IRQ) in the system. You must substitute your own ISR for the IRQs hat you want to use.

The question is which IRQ has called the ISR. You should be able to work out which IRQ has triggered by putting a break point on the ISR and looking at the registers.

Cocox might even have debug info which tells you which IRQ.

You can disable unused/un-wanted IRQs. The USB ISRs should be provided in the project.

Posted on January 03, 2014 at 13:30

USE_STDPERIPH_DRIVER

STM32F4XX

USE_STM324xG_EVAL

USE_USB_OTG_HS

USE_ULPI_PHY

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 03, 2014 at 15:36

hi,

with example I mean the library from UM1021

STM32F105/7, STM32F2 and STM32F4 USB on-the-go Host and device library (UM1021)

.

I want test the USB-Device, like transfer data from the board to the PC.

But that will

be inserted

later

, first I want a connection to the PC.

ok, I debug now the code step by step. I think it can be the TIM2_IRQHandler which makes problems.

The program goes in the infinite loop after the Function 'BSP_SetTime' in the 'usb_bsp.c'

This is a part of this function  /* Reset after a PHY select  */ USB_OTG_CoreReset(pdev);

 

Now I am

a little perplexed

what

is

to do now.

chen
Associate II
Posted on January 03, 2014 at 16:19

Hi

STM32F105/7, STM32F2 and STM32F4 USB on-the-go Host and device library (UM1021)

is a generic driver package which the end user must configure and write some stuff for themselves.

I think you would be better off with the example project/code from UM1492.

This is the example project for the development board that you have.

There is both a USB host example (reads USB memory stick)

and a USB device example (HID joystick).

The STM32 will be correctly configured for you and all the driver code is already there.

If you insist on continuing with what you have - remove the call to

'BSP_SetTime' in the 'usb_bsp.c' this is trying to set up the timer but you have not ported the ISR for this timer. Not setting it up will mean you do not need the ISR.

''does anyone have the code for the USB-HS''

There are many USB device and host drivers in

UM1021

- you must choose and port the one that you want.

chmielewski
Associate II
Posted on January 03, 2014 at 16:53

hi,

I have taken the VCP example from the USB_Device_Examples and the STM32_USB_Device_Library.

I assumed that the libary is ready to use, when I port it in the compiler.

The UM1492 is a hex-file. I can only load this in the board, but I can´t see then the code.

It would

help me a lot

if I had the

code

for this.

chen
Associate II
Posted on January 03, 2014 at 17:09

Hi

My appologies, I thought ST would also provide the source code for this demo.

Try the dev package :

http://www.st.com/web/en/catalog/tools/PF258142

The library code is already configured for your dev board.

You will still need to pick and choose what to use but at least there is less porting to do!

''I assumed that the libary is ready to use''

It is half ready to use. The lowest layers of the driver is there, the upper layers you have to produce eg for VirtualComPort (VCP) the lower layers get the data out of the USB and present it in buffers. You must write/port the upper layer (virtual com port driver) which pulls/pushes the data from the com port. The protocol is also up to you.

By the way I do not think you have understood that you need to choose between doing a

USB Host OR a USB device

If you do a USB device - you need to pick a device class eg CDC is a serial port

HID is keyboard, mouse or joystick

chen
Associate II
Posted on January 03, 2014 at 18:44

Hi

''I want test the USB-Device, like transfer data from the board to the PC.

But that will

be inserted

later

, first I want a connection to the PC.''

In which case you need to create a USB device of type CDC (serial device).

chmielewski
Associate II
Posted on January 06, 2014 at 14:22

hi,

I know the difference between USB Host and USB device. I want use it as USB device.

Thank you for your link, but i knew this already. This are the same librarys as in the UM1021 and a few more for other examples.

And there is an example for my development board, but for the EWARM, MDK-ARM and TrueSTUDIO IDE. Under EWARM I had a licence, but the test-version is expired. This is the reason why I use the librarys from ST to create me a own example and I hope so even leran more about the librarys.

Why I must write the upper layer for VirtualComPort? In the UM1021 is a library for the VCP and I have included it in my project.

In the example from EWARM it is solved with the VCP Library.

chen
Associate II
Posted on January 06, 2014 at 15:11

Hi

''Why I must write the upper layer for VirtualComPort? In the UM1021 is a library for the VCP and I have included it in my project.''

It depends on what you want the VCP port to do.

If the example code does what you want it to do, then you can just use their code.

The VCP example for a F4 discovery board echos back on the USART - so I have to change the code to do what I wanted it to do.