STM32F2 USB Driver
Hello,
I'm trying the STM3220G-EVAL board (STM32F207IG inside) with CrossWorks 2.1.2 connecting ST-Link/V2.
Using and debuging are OK , but USB is not good...
USB library is STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0.
This library contains the example project with IAR , Keil , RIDE but NOT CrossWorks.
So I setup the CrossWork project reference to the other files.
Both Host and Device are NG.
Run the Host project and insert the USB Memory.
Then Enumeration start but not complete forever.
The following 'IF' sentence never change to USBH_OK at file usbh_core.c
static USBH_Status USBH_HandleEnum(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
.....
case ENUM_GET_CFG_DESC:
if ( USBH_Get_CfgDesc(pdev, phost,USB_CONFIGURATION_DESC_SIZE) == USBH_OK) {
phost->EnumState = ENUM_GET_FULL_CFG_DESC;
}
It seems that reading from USB is something wrong.
Because , the program never goes to the GRXSTS_PKTSTS_IN: at following function
in the usb_hcd_int.c file.
static uint32_t USB_OTG_USBH_handle_rx_qlvl_ISR (USB_OTG_CORE_HANDLE *pdev)
...
switch (grxsts.b.pktsts)
{
case GRXSTS_PKTSTS_IN:
if ((grxsts.b.bcnt > 0) && (pdev->host.hc[channelnum].xfer_buff != (void *)0))
Never come here !
When run by IAR IDE the same project, it's OK.
I think that special setting is needed in project file.
I set the following preprocessor, other words are needed ?
USE_STDPERIPH_DRIVER
STM32F2XX
USE_USB_OTG_FS
__GNUC__
Please help me.
-
Thanks for the reply, Mr Michael.
I already increased the stack size that is too small with default setting (Heap,Stack -> 8192bytes),
and tried the all settings of optimisation (None,Level1,2,3), but can not improve.
It can not receive any packet at uint32_t USB_OTG_USBH_handle_rx_qlvl_ISR procedure as I mentioned before.
-
I've built the application.
I reproduced your original report with the Host Demo and a memory stick.
I changed the stack size to be 1024 and then that behaviour disappeared i.e. it seems to be working, but I'm not sure what the application should do. The main part of the LCD display is black - should something be displayed?
Regards
Michael
-
Thanks a lot for your testing !
We have to make a trick when showing the LCD display.
There is a 'PUTCHAR_PROTOTYPE' function in the lcd_log.c file (\Utilities\STM32_EVAL\Common\) that display the one character to LCD.
We have to "override" instead of the standard function '__io_putchar(int ch)'. This is writtern in the lcd_log.h.
But I can't do it, then give up the LCD display.
More importantly, " it semms to be working" ?
There is a function in the usb_hcd_int.c
static uint32_t USB_OTG_USBH_handle_rx_qlvl_ISR (USB_OTG_CORE_HANDLE *pdev)
{
.....
switch (grxsts.b.pktsts)
{
case GRXSTS_PKTSTS_IN:
/* Read the data into the host buffer. */
if ((grxsts.b.bcnt > 0) && (pdev->host.hc[channelnum].xfer_buff != (void *)0))
{v v v v v Break point here v v v v v
USB_OTG_ReadPacket(pdev, pdev->host.hc[channelnum].xfer_buff, grxsts.b.bcnt);^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
.....
}
Setting the break point showing above, then start the debugging and insert the USB memory at the OTG connector,
but NEVER HIT the break point.
While IAR environment ,setting the same break point, start debugging , insert the USB memory,
HIT the break point.
It seems that CrossWorks can not receive the USB packet.
Best Regards
Please sign in to leave a comment.
Comments
18 comments