Skip to main content
sonycman
Associate II
June 26, 2009
Question

Possible bug in STM32_USB-FS-Device_Lib_V3.0.1

  • June 26, 2009
  • 3 replies
  • 874 views
Posted on June 26, 2009 at 07:08

Possible bug in STM32_USB-FS-Device_Lib_V3.0.1

    This topic has been closed for replies.

    3 replies

    sonycman
    sonycmanAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 13:15

    Hello!

    I think I`ve found a bug in the STM32_USB-FS-Device_Lib_V3.0.1.

    It is in _SetEPTxStatus function.

    Here the code:

    #define _SetEPTxStatus(bEpNum,wState) {

    register uint16_t _wRegVal;

    _wRegVal = _GetENDPOINT(bEpNum) & EPTX_DTOGMASK;

    /* toggle first bit ? */

    if((EPTX_DTOG1 & wState)!= 0)

    _wRegVal ^= EPTX_DTOG1;

    /* toggle second bit ? */

    if((EPTX_DTOG2 & wState)!= 0)

    _wRegVal ^= EPTX_DTOG2;

    _SetENDPOINT(bEpNum, _wRegVal);

    } /* _SetEPTxStatus */

    STM32 endpoint registers USB_EPnR contain two rc_w0 bits, which are read_and_clear_by_write_zero of type.

    The code above reads this register, modify, and writes it back with these bits (rc_w0) left untouched.

    But if the bits initial state (just after reading) is 0, then by writing them back we just overwrite their new values!

    Because this bits state always may change between read\modify\write operations!

    Am I right, or just misunderstanding something?

    sonycman
    sonycmanAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 13:15

    Thanks!

    It seems no one knows the answer!

    I think, this bug might show up in very rare circumstances, this is why the library code does not process endpoint registers correctly...

    Also it seems that this library intended to use just for educational purposes, and not in serious projects, because of its primitive code...

    andreas2
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 13:15

    Good luck in getting an answer...

    http://www.st.com/mcu/forums-cat-8316-23.html