Skip to main content
STUser21
Associate II
October 23, 2020
Solved

STM32wb55, why is GPIO so slow ? How can it speed up?

  • October 23, 2020
  • 2 replies
  • 8260 views

Hi there,

I use the Nucleo-WB55 Board and I want to set some GPIO PINs in a high speed.

I use Low Level code to get fastest response.

GPIO_Init:

 GPIO_InitStruct.Pin = PID_D0_Pin|PID_D1_Pin;

 GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;

 GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;

 GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;

 GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;

 LL_GPIO_Init(GPIOC, &GPIO_InitStruct);

The CubeMX clock setup is at maximum speed with 32MHz

I set/reset the GPIO with LL command at the main.c

   LL_GPIO_ResetOutputPin(PID_D1_GPIO_Port,PID_D1_Pin); // time 0.00 µs

   LL_GPIO_ResetOutputPin(PID_D0_GPIO_Port,PID_D0_Pin); // time 720 ns 

It takes incredible 720ns until the D0 has turned off. It means there is a delay of 720ns until both Pin's D1 and D0 are off.

The LL_GPIO_ResetOutputPin() contains only  WRITE_REG(GPIOx->BRR, PinMask);

Did anyone know the reason why the GPIO set/reset need this much time?

If I do the same with an old 8bit 14MHz MCU it takes only 140ns!

We want to replace the old 8bit MCU with the STM32wb to have Bluetooth. But if the GPIO can not run with the same speed as the old 8bit, we have to search for another MCU.

Thanks a lot for any idea to speed up the STM32wb.

Ferdi

This topic has been closed for replies.
Best answer by TDK

If you want the fastest speed, use register level access. Ensure optimization settings are the highest.

GPIOD->BRR = GPIO_PIN_0 | GPIO_PIN_1;

You can examine the disassembly to see what code it's actually running.

2 replies

TDK
TDKAnswer
Super User
October 23, 2020

If you want the fastest speed, use register level access. Ensure optimization settings are the highest.

GPIOD->BRR = GPIO_PIN_0 | GPIO_PIN_1;

You can examine the disassembly to see what code it's actually running.

"If you feel a post has answered your question, please click ""Accept as Solution""."
STUser21
STUser21Author
Associate II
October 26, 2020

Thank's this helps a lot. Both PIN's are set at the same time.

:thumbs_up: