2020-05-26 07:36 AM
Hi I want to use the high resolution timer for a 10 bit resolution PWM output.
Even the ioc file tells me that it turns on 480 MHz but it doesn't.
I tested with a digital storage Oscilloscope the output of the PWM
I used the basic configuration so i have a simple PWM config to do.
The PWM is configured to give the update event each 2.13 microseconds, but it has 4.2 microseconds.
In the picture's below you have the Pictures of the clock config file, the main.c file, the HRTIM configuration in the .ioc file and the picture of the oscillosscope
Can you tell me why the HRTIM configuration for 480 MHz doesn't work?
2020-05-27 04:28 AM
I also feel that section 3.28 Timers and watchdogs in the datasheet is not clear.
2020-05-27 07:49 AM
Hi,
you can have a look at all needed registers with STM32IDE.
For example: Each timer in HRTIM can have it's own prescaler (CKPSC in HRTIM_MCR or HRTIM_TIMxCR).
Also look at "The maximum timer clock is up to 480 MHz depending on TIMPRE bit in the RCC_CFGR register and D2PRE1/2 bits in
RCC_D2CFGR register"
Kind regards
Daniel
2020-05-27 07:59 AM
Hi Daniel
Thanks for the Answer.
But my Problem is not the Prescaler.
As you can see on the picture "timer config", the configuration for the timer should work.
It prints out a frequency for the PWM update event, with this frequency the update Event should appear every 2.13 microseconds.
But suddenly the compiled code on the MC let the HRTIM work with 240 MHz and not 480 MHz.
You can check that with the oscilloscope output the PWM should have 2.13 microseconds and not 4.2 microseconds.
Friendly regards
Marco
2020-05-27 08:08 AM
Hi,
i see a picture of the Cube config. Cube config isn't perfect. You should have a look at the real values of all needed registers.
If all registers are correct you have to check the HAL. Perhaps the initialisation order isn't correct. Have a look at the reference manual (rm0433 rev7 p.1377)
Kind regards
Daniel
2020-06-29 06:29 AM
Edit: See the reply below for the solution.
Hello,
as I am currently experiencing a similar problem, I would like to step in here. I used CubeIDE with a CubeMX Project to configure the HRTIM with 400 MHz but it is running on half speed. I set the timer period to 4000 which should result in an output frequency of 100 kHz but instead I get 50 kHz. I am using HAL_Waveform, but for testing I just output a PWM signal where the output is set by the period event and reset by a compare event.
I had a look at HAL_HRTIM_TimeBaseConfig which configures prescaler and period. The function calls HRTIM_TimingUnitBase_Config in which the registers are updated:
/* Update the HRTIM registers */
hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR = hrtim_timcr;
hhrtim->Instance->sTimerxRegs[TimerIdx].PERxR = pTimeBaseCfg->Period;
hhrtim->Instance->sTimerxRegs[TimerIdx].REPxR = pTimeBaseCfg->RepetitionCounter;
The initialisation order is as requested by the reference manual:
> At start-up, it is mandatory to initialize first the prescaler bitfields before writing the compare
> and period registers. Once the timer is enabled (MCEN or TxCEN bit set in the
> HRTIM_MCR register), the prescaler cannot be modified.
2020-06-29 06:46 AM
After further investigation, this seems to be a bug in HAL_RCCEx_PeriphCLKConfig from version 1.7.0:
The following lines are taken from this function, it looks for a non existing definition of HRTIM, so the actual clock source is never set to CPU clock:
#if defined(HRTIM)
/*------------------------------ HRTIM1 clock Configuration ----------------*/
if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_HRTIM1) == RCC_PERIPHCLK_HRTIM1)
{
/* Check the parameters */
assert_param(IS_RCC_HRTIM1CLKSOURCE(PeriphClkInit->Hrtim1ClockSelection));
/* Configure the HRTIM1 clock source */
__HAL_RCC_HRTIM1_CONFIG(PeriphClkInit->Hrtim1ClockSelection);
}
#endif /*HRTIM*/
After changing the first line to #if defined(HRTIM1) (HRTIM1 is defined in stm32h743xx.h) it works with the expected frequency.
So the problem is indeed not about prescalers but originates from a bug in the HAL code. Is there any place to report such bugs?
2020-06-30 01:53 AM
Report bugs on github
2020-06-30 09:33 AM
Please create an issue against the above file/line (for version 1.8 !)
https://github.com/STMicroelectronics/stm32h7xx_hal_driver/issues
--pa
Ok I've already posted it - please review/comment :
https://github.com/STMicroelectronics/stm32h7xx_hal_driver/issues/7
in hope it can be fixed until the next release of CubeH7 package.