Can STM32F303RE send Comparator to both output pin and to Timer ?
I've configured my STM32F303RE to send the COMP4 to the output (PB1) as well as to TIM4_Ch2. I also am running an external signal generator in from PB6 to TIM4_Ch1.
I can see the COMP4 output on PB1 but not at the TIM4_Ch2. I can see the external signal being captured from TIM2_Ch1.
[Q] Can the COMP4 output be directed simultaneously to both the output pin and to the TIM4_Ch2 ?
If I modify the TIM4 initialization to send Ch1 to IC2 and Ch2 to IC1 I do see the signal generator capture move to the other capture register but the COMP4 is still not detected.
P.S. My comparator output also has multiple crossings from zero-crossing chatter.
static void MX_TIM4_Init(void)
{
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_IC_InitTypeDef sConfigIC = {0};
htim4.Instance = TIM4;
htim4.Init.Prescaler = 32;
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
htim4.Init.Period = 23500;
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim4) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_IC_Init(&htim4) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
sConfigIC.ICSelection = TIM_ICSELECTION_INDIRECTTI;
/* sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI; */
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
sConfigIC.ICFilter = 0;
if (HAL_TIM_IC_ConfigChannel(&htim4, &sConfigIC, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_IC_ConfigChannel(&htim4, &sConfigIC, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
HAL_TIM_Base_Start(&htim4);
}COMP4 Init:
static void MX_COMP4_Init(void)
{
/*##-1- Configure the COMP4 peripheral ################################*/
hcomp4.Instance = COMP4;
hcomp4.Init.InvertingInput = COMP_INVERTINGINPUT_DAC1_CH1;
hcomp4.Init.NonInvertingInput = COMP_NONINVERTINGINPUT_IO1;
hcomp4.Init.Output = COMP_OUTPUT_TIM4IC2;
hcomp4.Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
hcomp4.Init.BlankingSrce = COMP_BLANKINGSRCE_NONE;
hcomp4.Init.TriggerMode = COMP_TRIGGERMODE_NONE;
hcomp4.Init.Hysteresis = COMP_HYSTERESIS_NONE;
hcomp4.Init.WindowMode = COMP_WINDOWMODE_DISABLE;
if (HAL_COMP_Init(&hcomp4) != HAL_OK)
{
Error_Handler();
}
/*##-2- Start the comparator process ###############################*/
if (HAL_COMP_Start(&hcomp4) != HAL_OK)
{
Error_Handler();
}
}