How do you set STM32G031 advanced timer TIM1 clock source at the 128 MHz maximum frequency ?
- 3 replies
- 4760 views
Hello,
I'm currently working on an STM32G031G8U on a custom PCB. I can't really debug the code as I don't have access to ST-Link or SWDIO/SWCLK pins.
I haven't managed to set TIM1 internal clock to 128 MHz as stated in the reference manual (section 5.2.13) and the datasheet (section 3.16).
I'm currently using the TIM1 at 64 MHz to fire an interrupt every 64 µs. I reduced the ISR code to toggle a GPIO output pin (led), wait a few µs, and toggle the pin again. Then I observe pin output on an oscilloscope and I do measure the expected 64µs period. So far, so good.
When I try to set TIM1 at 128 MHz, the processor seems to go into fault mode (LED is not being driven anymore) instead of having a period twice as fast as the former one.
I used two configs on CubeMX to generate the RCC and TIM config code to set the timer at 128 MHz (refer to the attached pictures).
The first one uses TPCLK as input, but I think there's an issue with CubeMX for this config, as it uses a x2 multiplier although prescaler is set to 1. The reference manual actually contradicts that config stating that a prescaler value of 1 implie a multiplier value for TPCLK of 1.
The second config uses the PLLQ as input to run at 128 MHz ( M = 1, N = 16, R = 4, Q = 2, P = 2 with this latter one being grayed out). When I compile and run the code, the processor goes into fault mode although I'm using generated code.
I attached the source file. I tried to leave only the relevant code. I'm flashing the STM32 with a custom bootloader as well as a slightly custom linker script (to put some critical code on RAM), so you might not be able to compile and flash it on your side without some modifications.
The commented RCC config is the one at 64 MHz, working fine. The RCC config being compiled is the one that makes the processor go into fault, using PLLQ.
I did not put the config using TPCLK because I don't think it's a valid one.
If anyone has any clues as to why this fail, the help would be much appreciated.
Thank you in advance
