cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure a PWM, driven from a 128Mhz clock on the STM32G03x or STM32G07x?

JM1
Associate II

Relevant information in the datasheets and reference manual (RM0454) is lacking and/or confusion, but that 128Mhz can be achieved is clearly stated (STM32G030):

0693W00000KbfziQAB.png 

Cube also does allow for me to put in a 128 value for the ABP timer clocks (tested for both the STM32G030 and STM32G070), as shown below:

0693W00000Kbfu9QAB.png 

But when I look at the generated code (for TIM1), there is no code change when compared to the version generated for a 64Mhz input value. Note that Cube is erratic after changing values in this area: sometimes it updates the code sometimes it doesn't.

So my question is how to configure 128Mhz operation. Is it through the timer clock, or some center-aligned PWM configuration as suggested below:

0693W00000Kbg9nQAB.png 

That's it. Here's some extra tidbits found (from the refman):

0693W00000KbfxmQAB.png0693W00000Kbfy6QAB.png 

0693W00000KbfyfQAB.pngFrom the datasheet:

0693W00000Kbg2SQAR.png 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

The STM32G030 datasheet specifies 64 MHz max timer frequency.

https://www.st.com/resource/en/datasheet/stm32g030k8.pdf

0693W00000Kbgu0QAB.png 

Other STM32G0XX chips may support higher, which is consistent with "up to 128 MHz".

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
TDK
Guru

Seems like a CubeMX bug that lets you edit that field independently. It's not configurable independently of HCLK/APB Prescaler.

I can duplicate but I do get warning messages which indicate abnormal behavior.

If you feel a post has answered your question, please click "Accept as Solution".
JM1
Associate II

Hi there, thanks for the reply!

Yes, I got a flaky feeling about that too, especially as the refman suggests the X2 factor in Cube only works when there is a divider in the first place.

Yet the STM32G0 is advertised as having a 128Mhz capability, and I don't think I would be the first to want to use the MCU to its capabilities. This is pretty low hanging fruit to take advantage of.

AN5145 "Migration of applications from STM32F0 Series to STM32G0 Series" also mentions the difference and advertises the increased PWM resolution, to below 8 or 10ns.

Note I also did many (fruitless) searches on the Cube generated code to find a possible match, on terms like TIM1PCLK, PCLK, TIMxPCLK, etc.

TDK
Guru

The STM32G030 datasheet specifies 64 MHz max timer frequency.

https://www.st.com/resource/en/datasheet/stm32g030k8.pdf

0693W00000Kbgu0QAB.png 

Other STM32G0XX chips may support higher, which is consistent with "up to 128 MHz".

If you feel a post has answered your question, please click "Accept as Solution".
JM1
Associate II

Ouch. So I tested this with several G0x0 versions, including the STM32G070, and it seems all G0x0 don't feature the 128Mhz PWM.

For those wondering, using the STM32G071 I could configure 128Mhz:

0693W00000Kbh2OQAR.png 

So I guess the Cube bug and the blanket comments about 128MHz TIM1 capability put me on the wrong footing.

I'm glad it's worked out, thanks TDK.