Skip to main content
bernier-paul
Associate II
February 25, 2013
Question

STM32F4DISCOVERY, USB USE_ACCURATE_TIME

  • February 25, 2013
  • 3 replies
  • 813 views
Posted on February 25, 2013 at 21:49

Hi,

I use a STM32F4DISCOVERY, and I would like to begin to understant how the USB HOST/OTG works... ands it's not easy, there is a lot of files and lines of code. I saw in ST examples, that in stm32f4xx.c there is

void
TIM2_IRQHandler(
void
)

{
USB_OTG_BSP_TimerIRQ();
}

and then I saw that in usb_bsc.c it corresponds to the use of ''USE_ACCURATE_TIME''. I would like to know what's are the consequences if I removeUSE_ACCURATE_TIME and thus don't use the interrupt of TIM2. What is the purpose of the mecanismUSE_ACCURATE_TIME? I tried and it seems it still works, but is it less stable or reliable ? In addition if you have some tips to learn how usb host/otg on stm32f4 works, I'll take it ! :) Thank you !
    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    February 26, 2013
    Posted on February 26, 2013 at 01:57

    What version of the library are you looking at?

    Most of the ones using TIM2 assume a 72 MHz clock of the STM32F1xx series, other versions used the SysTick. The primary purpose being to generate millisecond and microsecond delays, presumably for GPIO signal placement, or reset pulses, etc.

    If the code you are using doesn't utilize them, no harm dumping them. Given they are just spinning in a loop the trace unit's cycle count would be equally effective.
    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    bernier-paul
    Associate II
    March 3, 2013
    Posted on March 03, 2013 at 19:21

    Thank you for your answer. It's the V2.0.0 of the USB OTG/HOST libraries.

    For instance the ''Audio_playback_and_record'' example from the set of 22 examples dedicated to the STM32F4DISCOVERY (http://www.st.com/web/en/catalog/tools/PF257904) uses the TIM2 interrupt (seen in stm32f4xx_it.c) . I don't know if not using it is a big issue...

    Tesla DeLorean
    Guru
    March 3, 2013
    Posted on March 03, 2013 at 22:09

    You'll observe that in both

    STM32F4-Discovery_FW_V1.1.0\Project\FW_upgrade\src\usb_bsp.c

    STM32F4-Discovery_FW_V1.1.0\Project\Audio_playback_and_record\src\usb_bsp.c

    The ''accurate'' clock for the BSP is based on a 72 MHz clock source, this code is not consistent with the 168 MHz the F4 uses in the project.

    It's used within the following for a VBus delay

    STM32F4-Discovery_FW_V1.1.0\Project\Audio_playback_and_record\src\usb_bsp.c

    The following use the timer for an enumeration delay

    STM32F4-Discovery_FW_V1.1.0\Project\Audio_playback_and_record\src\usbh_usr.c

    Look for the usage

    USB_OTG_BSP_uDelay()

    USB_OTG_BSP_mDelay()

    BSP_Delay() << less of any issue as it's static and not exported

    I'd probably port it to using SysTick or the DWT_CYCCNT

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..