Skip to main content
Lex Trc
Associate II
August 25, 2017
Question

Problem to reach high Frequency on GPIO

  • August 25, 2017
  • 5 replies
  • 1191 views
Posted on August 25, 2017 at 16:34

Hi,

i'm using stm32 nucleo board. The oscillator is configured to 32MHz speed.

Now, if i use the easy following code in the main:

while(1)

{

   HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, 1);

   HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, 0);

}

the frequency i measure on the LD2 pin is only 750KHz. This is really strange, i expect

to run more quick than 750KHz only.

Can someone help me?

    This topic has been closed for replies.

    5 replies

    Tesla DeLorean
    Guru
    August 25, 2017
    Posted on August 25, 2017 at 16:39

    Confirm what the CPU is running at internally. Internal clocks can be output via PA8 MCO pin.

    Use a lighter abstraction. Use optimization

    Use GPIO BSRR register in a direct write approach

    >>stm32 nucleo board

    That narrows the list to a 50+ boards, care to be more precise?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Lex Trc
    Lex TrcAuthor
    Associate II
    August 25, 2017
    Posted on August 25, 2017 at 16:46

    The board is a Nucleo L053R8. How can i send output frequency on PA08?

    Tesla DeLorean
    Guru
    August 25, 2017
    Posted on August 25, 2017 at 17:09

    Seek out the MCO examples in your chosen library. Review RCC registers in IDE of choice to confirm PLL and clock source settings.

    For PA8 driving via BSRR

    while(1)

    {

    GPIOA->BSRR = (1 << 8);

    GPIOA->BRR = (1 << 8);

    }

    Better to drive pin with a TIM

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    S.Ma
    Principal
    August 25, 2017
    Posted on August 25, 2017 at 17:02

    The HAL code favours portability at the expense of speed which is the purpose of the LL (low layer).

    Get LL cube examples from nucleo or discovery boards.

    Lex Trc
    Lex TrcAuthor
    Associate II
    September 12, 2017
    Posted on September 12, 2017 at 14:15

    thanks everybody