Event change state output pin in example TIM_OCToggle
Hi, i have implemented the example TIM_OCToggle from stm32f40xx to stm32f103xx, both work fine.
I want a event in the moment change state output pin of the channels OC, as occurs in the events:HAL_TIM_PeriodElapsedCallback or HAL_TIM_PWM_PulseFinishedCallback
int main(void)
{ HAL_Init(); SystemClock_Config(); InitConfigTIM2_OC(); while (1) { }}static void InitConfigTIM2_OC(void)
{ TIM_ClockConfigTypeDef sClockSourceConfig; TIM_MasterConfigTypeDef sMasterConfig; TIM_OC_InitTypeDef sConfigOC; uint32_t uhPrescalerValue = 0; uhPrescalerValue = (uint32_t)(SystemCoreClock / 1000000) - 1;hTIM2.Instance = TIM2;
//hTIM2.Init.Prescaler = 2000-1; hTIM2.Init.Prescaler = uhPrescalerValue; hTIM2.Init.CounterMode = TIM_COUNTERMODE_UP; hTIM2.Init.Period = 50; hTIM2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; hTIM2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; HAL_TIM_Base_Init(&hTIM2); HAL_TIM_OC_Init(&hTIM2);sConfigOC.OCMode = TIM_OCMODE_TOGGLE;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.Pulse = uhCCR3_Val; HAL_TIM_OC_ConfigChannel(&hTIM2, &sConfigOC, TIM_CHANNEL_3);sConfigOC.Pulse = uhCCR4_Val;
HAL_TIM_OC_ConfigChannel(&hTIM2, &sConfigOC, TIM_CHANNEL_4);HAL_TIM_MspPostInit(&hTIM2);
HAL_TIM_OC_Start_IT(&hTIM2, TIM_CHANNEL_3);
HAL_TIM_OC_Start_IT(&hTIM2, TIM_CHANNEL_4); }void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim)
{ if(htim->Instance == TIM2) { if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_3) { uhCapture = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_3); __HAL_TIM_SET_COMPARE(&hTIM2, TIM_CHANNEL_3, (uhCapture + uhCCR3_Val)); } if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_4) { uhCapture = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_4); __HAL_TIM_SET_COMPARE(&hTIM2, TIM_CHANNEL_4, (uhCapture + uhCCR4_Val)); } }}#stm32f103-event