USB HID development - Keil or ST middleware ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-07-28 8:08 PM
Posted on July 29, 2015 at 05:08
Hello,
I have started a project where I need to implement USB HID on STM32F4 I have a custom board and a STM32F429I-Discovery board. So I would like an advice from somebody with experience - which middleware USB stack is preferable - Keil or ST ? I've started with Keil - implemented the HID example for the discovery board. And faced the problem right away: When I program the flash for the fist time, the board is enumerated ok and sending reports both ways. Until I cycle power. After that the program is waiting for a soft reset in a USBD_HS_STM32F4xx.c driver file:static int32_t USBD_PowerControl (ARM_POWER_STATE state) {
switch (state) {
case ARM_POWER_OFF:
.....................................
break;
case ARM_POWER_FULL:
if ((otg_hs_state & OTG_HS_USBD_DRIVER_POWERED) != 0U) { return ARM_DRIVER_OK; }
RCC->AHB1ENR |= RCC_AHB1ENR_OTGHSEN; // OTG HS clock enable
RCC->AHB1RSTR |= RCC_AHB1RSTR_OTGHRST; // Reset OTG HS module
osDelay(1U);
RCC->AHB1RSTR &= ~RCC_AHB1RSTR_OTGHRST; // Clear reset of OTG HS module
osDelay(1U);
#ifdef MX_USB_OTG_HS_ULPI_D7_Pin
// External ULPI High-speed PHY
RCC->AHB1ENR |= RCC_AHB1ENR_OTGHSULPIEN; // OTG HS ULPI clock enable
#else
// On-chip Full-speed PHY
OTG->PCGCCTL &= ~OTG_HS_PCGCCTL_STPPCLK; // Start PHY clock
OTG->GCCFG |= OTG_HS_GCCFG_PWRDWN; // Disable power down
OTG->GUSBCFG |= OTG_HS_GUSBCFG_PHSEL | // Full-speed transceiver
OTG_HS_GUSBCFG_PHYLPCS; // 48 MHz external clock
#endif
OTG->GRSTCTL |= OTG_HS_GRSTCTL_CSRST; // Core soft reset
/* never goes beyond this */
while ((OTG->GRSTCTL & OTG_HS_GRSTCTL_CSRST) != 0U);
And it's strange, since the system viewer shows that the
OTG_HS_GRSTCTL_CSRST
bit is set.
Now, the reprogramming of the flash doesn't fix the problem
Neither chip erase / reprogramming does. But if I load the demo firmware and then program the HID example, it works again - till the next power cycle. If I comment the soft reset out, everything works fine. Keil tech support is currently trying to figure out what is going on. Except of the HID the controller is going to have quite a few of other functions - multiple SPIs, I2Cs, UARTs etc. So I am not sure how RTOS used in Keil's USB stack will effect the rest of operation. At the same time Keil seems easier to work with. Anyway, can somebody please give an opinion on a subject based on experience ? Thank you, Gennady
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-08-28 10:07 AM
Posted on August 28, 2015 at 19:07
Hello,
I have the same problem on STM32F429I-Discovery and MDK5
. Hope somebody can help us? Thanks, DangOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-08-28 10:26 AM
Posted on August 28, 2015 at 19:26
Hope somebody can help us?
Tried Keil's support? Presumably there's a reason for licensing the tools, and using the middleware?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-08-28 11:26 AM
Posted on August 28, 2015 at 20:26
Hi Clive1,
Thanks for you answer! I thinkI
have solved
this problem
already.
Firstly, I remove read only attribute of USBD_HS_STM32F4xx.c file. Secondly, modify it like this:...
OTG->GAHBCFG |= OTG_HS_GUSBCFG_ULPIFSLS; // Add this line
OTG->GRSTCTL |= OTG_HS_GRSTCTL_CSRST; // Core soft reset
while ((OTG->GRSTCTL & OTG_HS_GRSTCTL_CSRST) != 0U);
osDelay (1U);
...
Finally, build code again and enjoy!
Regards,
Dang
