Skip to main content
STUser21
Associate II
Oct 23, 2020 12:08 PM UTC
Solved

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

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.
TDK
TDKBest answer
Oct 23, 2020 1:06 PM UTC

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""."

2 replies

TDK
TDKBest answer
Oct 23, 2020 1:06 PM UTC

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
Oct 26, 2020 12:12 PM UTC

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

:thumbs_up: