2019-04-25 12:39 AM
Dear Member,
I use timer 3 for generating a tone,
is this configuration right, for generating 30KHz ?
Chip = STM32L152RE, Clock 2.097MHz
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};
htim3.Instance = TIM3;
htim3.Init.Prescaler = (SystemCoreClock/1000000)-1;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 2097000/33000;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
Thanks
2019-04-25 03:45 PM
Hi
No need to prescale
Prescaler=0 and Period 2097000/33000-1 =63
Period 63 gives update frequency 32765 Hz
Period 62 gives update frequency 33285 Hz
2019-12-24 09:02 PM
htim3.Init.Prescaler = 0;
htim3.Init.Period = 2097000/33000-1;
Right ?
2019-12-24 10:57 PM
Well, I used on STM32L4R the LPTIM1 to generate buzzer tone. works fine and easy to do.
SYSCLK = 48Mhz, LPTIM = 3 MHz.