AnsweredAssumed Answered

Bug in HAL_PCD_Init: Wrong HBSTLEN value

Question asked by hartung.robert on Aug 14, 2015
Latest reply on Dec 23, 2015 by Nesrine M
I have been writing my own USB driver. While debugging an issue with the receive buffer/receive fifo I came across this issue.

I am using an STM32F205VCT processor with an external HS Phy (USB3300). The function HAL_PCD_Init calls the function USB_CoreInit and it will initialize the required registers. I am using DMA. So this code will be executed:

if(cfg.dma_enable == ENABLE)
  {
    USBx->GAHBCFG |= (USB_OTG_GAHBCFG_HBSTLEN_2 | USB_OTG_GAHBCFG_HBSTLEN_1);
    USBx->GAHBCFG |= USB_OTG_GAHBCFG_DMAEN;
  }

with

#define USB_OTG_GAHBCFG_HBSTLEN_1               ((uint32_t)0x00000004)            /*!<Bit 1 */
#define USB_OTG_GAHBCFG_HBSTLEN_2               ((uint32_t)0x00000008)            /*!<Bit 2 */

Unfortunately, this will be evaluated to be "0b1100" and will be or'd onto the register. Resulting in a value of "0b0110" for the HBSTLEN value. Unfortunately, this is an invalid value, but no error is thrown!

Can someone verify this? The Code was initially generated with the latest version of cubemx!

If you would like to get more information on my USB Driver, just let me know.

Outcomes