STM32F407 Clock bus speeds

Discussion in 'Embedded Systems and Microcontrollers' started by Shagas, Oct 6, 2014.

  1. Shagas

    Thread Starter Active Member

    May 13, 2013
    802
    74
    Hello

    I have a few questions about the clock system in the stm32F4 MCU .
    I understand that there is a system clock with a max speed of 168 , then there are the ABP1 ,ABP2 busses with
    maximum speeds of 48Mhz and 84Mhz respectively.
    I've used the stm32 excel clock tool and successfully clocked the MCU at 168Mhz Using the External Xtal as the source.

    My question: What speed are the ABP1/2 and AHB busses running at? Can I prescale them from the system clock?
    Question 2: Why are there more than one AHB busses? Do they each have their own prescaler from the system clock ?

    Thanks in advance
     
  2. Shagas

    Thread Starter Active Member

    May 13, 2013
    802
    74
    Ok so I've found my answer in the system file generated by the STM32 clock tool :)
    Sorry for the "blank" post , I needed an answer fast.

    Code (Text):
    1.  
    2. *=============================================================================
    3.   *=============================================================================
    4.   *        Supported STM32F40xx/41xx/427x/437x devices
    5.   *-----------------------------------------------------------------------------
    6.   *        System Clock source                    | PLL (HSE)
    7.   *-----------------------------------------------------------------------------
    8.   *        SYSCLK(Hz)                             | 168000000
    9.   *-----------------------------------------------------------------------------
    10.   *        HCLK(Hz)                               | 168000000
    11.   *-----------------------------------------------------------------------------
    12.   *        AHB Prescaler                          | 1
    13.   *-----------------------------------------------------------------------------
    14.   *        APB1 Prescaler                         | 4
    15.   *-----------------------------------------------------------------------------
    16.   *        APB2 Prescaler                         | 2
    17.   *-----------------------------------------------------------------------------
    18.   *        HSE Frequency(Hz)                      | 8000000
    19.   *-----------------------------------------------------------------------------
    20.   *        PLL_M                                  | 8
    21.   *-----------------------------------------------------------------------------
    22.   *        PLL_N                                  | 336
    23.   *-----------------------------------------------------------------------------
    24.   *        PLL_P                                  | 2
    25.   *-----------------------------------------------------------------------------
    26.   *        PLL_Q                                  | 7
    27.   *-----------------------------------------------------------------------------
    28.   *        PLLI2S_N                               | NA
    29.   *-----------------------------------------------------------------------------
    30.   *        PLLI2S_R                               | NA
    31.   *-----------------------------------------------------------------------------
    32.   *        I2S input clock                        | NA
    33.   *-----------------------------------------------------------------------------
    34.   *        VDD(V)                                 | 3.3
    35.   *-----------------------------------------------------------------------------
    36.   *        Main regulator output voltage          | Scale1 mode
    37.   *-----------------------------------------------------------------------------
    38.   *        Flash Latency(WS)                      | 5
    39.   *-----------------------------------------------------------------------------
    40.   *        Prefetch Buffer                        | OFF
    41.   *-----------------------------------------------------------------------------
    42.   *        Instruction cache                      | ON
    43.   *-----------------------------------------------------------------------------
    44.   *        Data cache                             | ON
    45.   *-----------------------------------------------------------------------------
    46.   *        Require 48MHz for USB OTG FS,          | Disabled
    47.   *        SDIO and RNG clock                     |
    48.   *-----------------------------------------------------------------------------
    49.   *=============================================================================
    50.   ******************************************************************************
     
  3. Shagas

    Thread Starter Active Member

    May 13, 2013
    802
    74
    But perhaps someone could advise as to what the following attributes are and how they can be used/useful :

    Flash latency(WS)
    Prefetch buffer
    Data cache
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    The CPU running at top speed (168MHz) runs faster than the rate at which instructions and data can be fetched from flash memory.
    Hence wait states (5) are required between when instruction/data are requested and when they become available.

    To overcome this delay, instructions and data are prefetched and stored in the instruction cache and data cache. On normal pipeline execution there is no slowdown until you hit a branch instruction in which case the cache must be refreshed and it cost you a 5 WS penalty.
     
    absf likes this.
  5. Shagas

    Thread Starter Active Member

    May 13, 2013
    802
    74
    Thanks for the reply. Could you give an example of such a branch instruction which would cost 5 WS?
    Am I correct to assume that If I set the system clk to say 16Mhz then I should always set the WS to 1 ?
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    I assume that this is a hypothetical question, i.e. you are not really planning on using an external 16MHz clock.

    Typically, one would simply follow the application notes where an 8MHz crystal is employed. The internal configuration will set the PLL so that the correct SYSCLK of 168MHz is generated. Note that you will need 48MHz if you plan on using the on-chip USB functions.

    Hypothetically, if you want to decrease SYSCLK to 16MHz, you will need zero WS, i.e. no waiting.

    As for a hit/miss in the instruction/data pipeline, if the required data or the next instruction to be executed (i.e. destination of a branch instruction) is not already in the cache, then a miss occurs. The cache has to be refreshed and hence the processor has to wait for the preprogrammed number of wait states before continuing.
     
  7. Shagas

    Thread Starter Active Member

    May 13, 2013
    802
    74
    Thanks for the reply. Yes , it was a hypothetical question.
    I'm going to be clocking the stm32 at 84Mhz or 168Mhz for my quadcopter project. The discovery has an 8Mhz external XTAL and I'm going to keep it that way when I make my own board.
     
Loading...