2019-09-23 06:51 AM
2019-09-23 11:59 PM
IS there any update?
void MX_TIM3_Init(void)
{
__HAL_RCC_TIM3_CLK_ENABLE();
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
htim3.Instance = TIM3;
htim3.Init.Prescaler = 320;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 100;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
HAL_TIMEx_RemapConfig(&htim3,TIM3_TI2_GPIOB5_AF4);
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 50;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_ENABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
}
this is timer initialization.
Any external event is affecting the PWM.
I am using LoRa as well.
what is missing in this?
2019-09-24 06:48 AM
Shorts between SPI and TIM pins?
Unstable power resetting MCU?
JW
2019-09-24 10:26 PM
No there is no short between timer and SPI pins. I have also tried using another timer on another pin but same issue.
Is my timer configuration correct?
Am I missing something?
2019-09-24 11:27 PM
I don't use Cube, but as long as you set a timer to generate PWM and then don't touch its registers, and unless it's in one-pulse mode, it should tick regularly to infinity.
JW