2021-01-03 12:01 AM
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
//TimHandle.Instance = TIM1;
HAL_TIMEx_ConfigCommutEvent_IT(&htim1, TIM_TS_NONE, TIM_COMMUTATION_SOFTWARE);
/* USER CODE END Init */
/////////////////////////////////////////////////////////////////////////////////////////
/* USER CODE BEGIN 4 */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim){
if(htim->Instance == (TIM2)){
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_14);
HAL_TIM_GenerateEvent(&htim1, TIM_EventSource_COM);
//count++;
//BRG_switch(); //<-this call is working
}
//if(htim->Instance == (TIM1)){pwm++;}
}
void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim1){
count++;
BRG_switch(); //<-this call is not working!
}
Solved! Go to Solution.
2021-01-03 05:21 AM
YEP, sorry, I found the answer. The
HAL_TIMEx_ConfigCommutEvent_IT(&htim1, TIM_TS_NONE, TIM_COMMUTATION_SOFTWARE);
HAS TO BE AFTER MX_TIM1_Init();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_TIM1_Init();
MX_ADC1_Init();
MX_TIM2_Init();
/* USER CODE BEGIN 2 */
//TimHandle.Instance = TIM1;
HAL_TIM_Base_Start_IT(&htim2);
HAL_TIM_Base_Start_IT(&htim1);
HAL_TIM_Base_MspInit(&TimHandle);
HAL_TIMEx_ConfigCommutEvent_IT(&htim1, TIM_TS_NONE, TIM_COMMUTATION_SOFTWARE);
// TIM1->DIER|=TIM_DIER_UIE;
//TIM1->DIER|=TIM_DIER_COMIE;
//__HAL_TIM_ENABLE_IT(&htim1, TIM_IT_COM);
2021-01-03 05:21 AM
YEP, sorry, I found the answer. The
HAL_TIMEx_ConfigCommutEvent_IT(&htim1, TIM_TS_NONE, TIM_COMMUTATION_SOFTWARE);
HAS TO BE AFTER MX_TIM1_Init();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_TIM1_Init();
MX_ADC1_Init();
MX_TIM2_Init();
/* USER CODE BEGIN 2 */
//TimHandle.Instance = TIM1;
HAL_TIM_Base_Start_IT(&htim2);
HAL_TIM_Base_Start_IT(&htim1);
HAL_TIM_Base_MspInit(&TimHandle);
HAL_TIMEx_ConfigCommutEvent_IT(&htim1, TIM_TS_NONE, TIM_COMMUTATION_SOFTWARE);
// TIM1->DIER|=TIM_DIER_UIE;
//TIM1->DIER|=TIM_DIER_COMIE;
//__HAL_TIM_ENABLE_IT(&htim1, TIM_IT_COM);