HAL USB host HS in FS with FreeRTOS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-19 1:22 AM
Hi all,
I'am communicating with a 3G modem through USB.
I'am using FreeRTOS (this is important).The USB is configurated like :/*Set LL Driver parameters */
hhcd.
Instance
= USB_OTG_HS;hhcd.
Init.
Host_channels= 11;
hhcd.
Init.
dma_enable= 1;
hhcd.
Init.
low_power_enable= 0;
hhcd.
Init
.phy_itface
= HCD_PHY_EMBEDDED;hhcd.
Init.
Sof_enable= 0;
hhcd.
Init
.speed
= HCD_SPEED_HIGH;hhcd.
Init.
vbus_sensing_enable= 0;
hhcd.
Init.
use_external_vbus= 0;
My problem is the following:
Sending small datas (simple AT command) to the modem is OK.
char
at[] =
''ATE0\r\n'';
USBH_CDC_Transmit(&hUSB_Host, (
uint8_t
*) at, (uint32_t
)strlen
(at));but sending more bigger data is a problem.
If the data is bigger than 64 (USB frame size) the transmit do not end.If I add an osDelay(1) in the main USB thread ( USBH_Process_OS() ) thetransmit ends !If I add a new thread to manage data received by the modem, the transmit ends !But those workaround hide a bigger problem.I suspect a FreeRTOS schedule and/or interrupt priority problem. So far I didn't managed to identifie it.If someone has faced same problems please share your experience and/or fix,Thanks,Best Regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-24 8:13 AM
I'am answering to my own question.
There is a problem (don't know why yet) with USB_OTG_HCCHAR_CHDIS and USB_OTG_HCCHAR_CHENA registers.Writing in it ''too early'' will overwrite it and crash (?) the USB.Adding :
while
((USBx_HC(hc->ch_num
)->HCCHAR
& USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);in USB_HC_StartXfer before addressing theses register correct the problem.To me this is only a workaround. The root cause should be addressed. I suspect a concurrence problem between main USB thread and USB interrupt.I didn't investigate more so far.Hope that help,Best regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-06-24 8:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-09-22 10:16 AM
hi, pillet.vincent.
Sorry for my bad english. I'm from Brazil.I'm also working with 3g modem. I'm not able to switch the modem mode to CDC. The 3g modem always stay in MSC class. How do it?you could post your code?Thanks.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-01-31 7:54 PM
This workaround solved my problem of unreliable sends with CDC host. The bug still exists in STMCubeF7 V1.8.0. In addition, the same function also appears to have another bug in that the tmpreg variable is oddly declared static and so the function is NOT thread-safe.
