cancel
Showing results for 
Search instead for 
Did you mean: 

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

STUser21
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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

View solution in original post

2 REPLIES 2
TDK
Guru

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
Associate II

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

:thumbs_up: