2021-08-04 05:02 AM
the following line 56000000 is wrong.
#define PRESCALER_VALUE (uint32_t)((SystemCoreClock / 56000000) - 1)
it should be 5600000 Right ?
SystemCoreclock is 16MHZ. but divided by 56MHZ ?
Solved! Go to Solution.
2021-08-04 06:43 AM
SystemCoreClock is 56000000.
Which makes PRESCALER_VALUE = 0.
Which makes the timer tick at 56 MHz.
Since period is 2295, the frequence is 24 kHz.
Which is exactly what the example says it does. No bug.
2021-08-04 06:43 AM
SystemCoreClock is 56000000.
Which makes PRESCALER_VALUE = 0.
Which makes the timer tick at 56 MHz.
Since period is 2295, the frequence is 24 kHz.
Which is exactly what the example says it does. No bug.
2021-08-05 01:48 AM
Thanks for the reply.
this is declared in system_stm32g0xx.c
uint32_t SystemCoreClock = 16000000UL; I checked it while application is running it is same. not increased to 64MHZ.
with this setting it is not working for me. in this case
#define PRESCALER_VALUE (uint32_t)((SystemCoreClock / 56000000) - 1) equals to -1 not zero.
I set PRESCALER_VALUE = 0; then output is coming at 6.97khz
I need to increase SystemCoreClock to 64 MHz. how to do that ?
2021-08-05 02:12 AM
sorry. I found void SystemClock_Config(void) is different in my application. copied it from Example and now SystemClock is set to 56 Mhz.
after this I am getting 24.4Khz. PWM output.
Thank you very for the help.
2021-08-05 07:14 AM
Glad you got it working.
As additional info, the chip boots up in 16 MHz, so this is the initial (and correct) value of SystemCoreClock.
When the clock changes, the SystemCoreClock variable is updated accordingly, at least if you're using HAL.