Electronics > Microcontrollers

Problems with STM32L051C8T6 GPIO Output High Frequency

(1/3) > >>

Shell Albert:
Hi, guys.
I really need help so I come here.
I'm using STM32L051C8T6 in my low-power-consumption design.
For some peripheral devices accessing, I need to accelerate timing speed.
So I test how fast GPIOs can go. 
I generated a very simple project using STM32CubeIDE, only 4 lines were added by manual.
When I measured GPIO with an oscilloscope, it can't reach a high frequency.
it's only 250KHz! 
and I also configure GPIO to Very HIGH output mode.

That’s so weird, in my opinion, HAL_GPIO_WritePin() can’t take up much time, and __NOP() only takes up one clock period. But the reality breaks my thought. What’s going on here?
And how can I output a very high frequency from GPIO? For example, 2MHz.

Does anyone have experience with STM32L051C8T5? 

This toggling frequency has nothing to do with the GPIO speed. The speed configuration is the drive strength. It is useful to limit the EMC and  possibly for impedance matching, but it does not affect toggling frequency, it just sets how "soft" your edges would be.

Is your input clock actually 32 MHz? Show full schematic.

EDIT: I see you are using HSI RC and PLL. In any event verify that the clock  is correct.

And then look inside HAL_GpioWritePin(). See how much code is there. And then check compiler optimization settings.

Attach the resulting ELF file too.

Shell Albert:
Thanks for your reply, sir.
I follow your guide and check my design carefully.

First, the external clock frequency on PCB is 32MHz indeed, I confirmed that with an oscilloscope. 
And I enabled “Master Clock Output 1” feature, and STM32 output main clock through PA8, I measured this pin with an oscilloscope, it was 32MHz.

Whether I use HSE or HSI, I make sure the system runs at 32MHz, I measured “Master Clock Output 1” with an oscilloscope, it was 32MHz, there was no doubt.

Then I go to check HAL_GPIO_WritePin() function, it checks parameters validation, then operates registers directly.
The last point you mentioned, I checked again, No Optimization Enabled.

This is a very tiny code project to output a fixed frequency wave. What’s going on? Did I miss something?  This really confused me.

Then My colleagues suggested me to update STM32CubeIDE to latest version.
The version I’m using is V1.14.1, the latest version on ST.com is V1.15.1,

After I eliminated old version and updated to the latest version, nothing changed, I still can’t get a correct consequence.

Does anyone do me a favor?

Well, how big are those asserts?

Enable optimization and see if it improves things. Then remove those asserts and check if that improves things.

And then look at the disassembly and see how much code there actually is.

Shell Albert:
Whether I use HSE(External Clock) or HSI(Internal Clock), the consequence is incorrect.

I make sure the system runs at 32MHz,

I enable "Master Clock Output 1" feature, So I can measure through PA8. 

I measured PA8 with an oscilloscope, it was 32MHz indeed.

If someone could offer help, no matter how small, it will be appreciated.

Got trapped in this problem for nearly a week, I'm going insane. I'm thinking if it's ST company's fault, STM32L051C8T6 is in less fabrication, only few people use it, some bugs can't be revealed and fixed.


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod