cancel
Showing results for 
Search instead for 
Did you mean: 

Problem to reach high Frequency on GPIO

Lex Trc
Associate II
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?

5 REPLIES 5
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
Up vote any posts that you find helpful, it shows what's working..
Lex Trc
Associate II
Posted on August 25, 2017 at 16:46

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

S.Ma
Principal
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.

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
Up vote any posts that you find helpful, it shows what's working..
Lex Trc
Associate II
Posted on September 12, 2017 at 14:15

thanks everybody