cancel
Showing results for 
Search instead for 
Did you mean: 

USB: High Speed core with embedded phy

mark2399
Associate II
Posted on January 22, 2014 at 16:12

Hi,

From reading the documentation, I gathered that it is possible to use the high speed core with the embedded full speed phy. I understand that I'd be limited to full speed with this setup but I believe that with the high speed core I get the benefit of DMA access?

I'm currently using the stm32f4 discovery board but will soon be switching to a dedicated target board. In a discovery board example the usb_bsp.c file notes that on the discovery board only the FS core is supported.

I now a little confused:

1) Why is the HS core (an internal peripheral) not supported on the discovery board?

2) Is it possible to even connect the HS core to the embedded FS phy

3) If so, is it even worth bothering to use this implementation? (note that we are intending to get as high a data rate as possible out of the FS connection while minimising CPU load)

Lastly, as a minimum we need to achieve at least continual 2Mb/s using either CDC (virtual COM port) or USB Test and Measurement Class (USBTMC)

any help would be greatly appreciated.

regards,

Mark

#stm32 #discovery #usb #stm32f4
4 REPLIES 4
chen
Associate II
Posted on January 23, 2014 at 11:52

Hi

'' I gathered that it is possible to use the high speed core with the embedded full speed ''

Yes, this simply means that USB2 is backwards compatible with USB1.

See

http://en.wikipedia.org/wiki/USB

''1) Why is the HS core (an internal peripheral) not supported on the discovery board?''

Look at the datasheet for this Discovery board, look at the schematic/circuit diagram. The USB connector is wired to certain pins of the processor. Each pin of the processor has certain functions associated to that pin - only those functions are available on that pin.

ie If the Discovery board only uses the FS USB port then that is what is available on the Discovery board. If you want to add the HS USB port - you will have to use the pin header.

''2) Is it possible to even connect the HS core to the embedded FS phy''

Yes I think it is but why would you want to connect one USB port of the processor to the other?

''Lastly, as a minimum we need to achieve at least continual 2Mb/s using either CDC (virtual COM port) or USB Test and Measurement Class (USBTMC)''

Technically, CDC is an simulation of a serial port, so you are limited to what data rates a serial port supports! I doubt 2Mb/s is technically possible on a serial port - more like 115.2K/s. However, saying that USB is capable of that kind of speed, it is dependent on the CDC/VCP implementation (I would not want to rely on it professionally!).

I do not know much about USB Test and Measurement Class (USBTMC).

mark2399
Associate II
Posted on January 23, 2014 at 13:28

Hi,

Thanks for the reply. comments inline...

'' I gathered that it is possible to use the high speed core with the embedded full speed ''

Yes, this simply means that USB2 is backwards compatible with USB1.

See 

http://en.wikipedia.org/wiki/USB

''1) Why is the HS core (an internal peripheral) not supported on the discovery board?''

Look at the datasheet for this Discovery board, look at the schematic/circuit diagram. The USB connector is wired to certain pins of the processor. Each pin of the processor has certain functions associated to that pin - only those functions are available on that pin.

ie If the Discovery board only uses the FS USB port then that is what is available on the Discovery board. If you want to add the HS USB port - you will have to use the pin header.

Just to clarify here, I'm talking about the internal HS core, not the phy layer. According to the STM document: UM1021, the HS core can connect to the embedded phy or to an external phy.

''2) Is it possible to even connect the HS core to the embedded FS phy''

Yes I think it is but why would you want to connect one USB port of the processor to the other?

As I stated earlier, I believe the HS core allows the use of DMA which will remove load from the CPU.

''Lastly, as a minimum we need to achieve at least continual 2Mb/s using either CDC (virtual COM port) or USB Test and Measurement Class (USBTMC)''

Technically, CDC is an simulation of a serial port, so you are limited to what data rates a serial port supports! I doubt 2Mb/s is technically possible on a serial port - more like 115.2K/s. However, saying that USB is capable of that kind of speed, it is dependent on the CDC/VCP implementation (I would not want to rely on it professionally!).

I do not know much about USB Test and Measurement Class (USBTMC).

According to the docs it seems to be possible to use the HS core with the embedded phy (UM1021, section 4.2, second bullet point) but I have been unable to get anything working (no USB related interrupts occur when I enable HS). Also, in the file usb_bsp.c for various examples, the GPIO pin setup is configured for different pins than the embedded phy and for a particular example for the discovery board there is a comment stating that the HS core cannot be used. Perhaps they're only talking about the external phy situation.

regards,

Mark

chen
Associate II
Posted on January 23, 2014 at 14:11

Hi

''

. Also, in the file usb_bsp.c for various examples, the GPIO pin setup is configured for different pins than the embedded phy and for a particular example for the discovery board there is a comment stating that the HS core cannot be used.

''

As I said earlier - the discovery board is designed to use one particular USB peripheral - unfortunately for you it is the FS peripheral, not the HS.

''

According to the docs it seems to be possible to use the HS core with the embedded phy (UM1021, section 4.2, second bullet point)

''

OK - you mention this 'manual'. It references a different development board then the Discovery. Try downloading the datasheets, manuals for that dev board - it may have the reference design you are looking for.

Sorry that is the best I can offer!

mark2399
Associate II
Posted on January 29, 2014 at 11:10

Hi,

Thanks for your help, I now understand what you were trying to explain.

I have got the high speed core working now using the low speed phy. As you suggested, the discovery board's micro usb connector is hardwired to the low speed phy. However, it is possible to access the high speed core (attached to the low speed phy) on pins PB12, PB14, PB15. In order to achieve this a small piece of vero board was used to connect a USB B connector to these pins.

The main thing that confused me was that I was expecting the full speed phy to be connected only to the one set of physical pins. In reality, the (seemingly) same full speed phy is connected to different pins when you're using the high speed core.

For anyone else wishing to achieve the same these are the rough steps:

*Firstly, get the full speed core STM code working

* Change the defines to contain: USE_USB_OTG_HS  and USE_EMBEDDED_PHY (preferably in the makefile)

initialisation in the bsp file should be something along these lines:

/////////////////////////

RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOB , ENABLE);

/* Configure SOF VBUS ID DM DP Pins */

GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_14 |

GPIO_Pin_15;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOB,GPIO_PinSource14,GPIO_AF_OTG2_FS);

GPIO_PinAFConfig(GPIOB,GPIO_PinSource15,GPIO_AF_OTG2_FS);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;

GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_OTG2_FS);

//  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_OTG_HS, ENABLE) ;

/* enable the PWR clock */

RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE);

///////////////////////////////////////////

Finally initialise USB stack as a high speed core:

USBD_Init(&USB_OTG_dev, USB_OTG_HS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);

Note that this code has only been used to initialise as a device as we're not currently interested in host.

regards,

Mark