cancel
Showing results for 
Search instead for 
Did you mean: 

2 Timers use with stm32F746BG

Yuriy Pankratz
Associate II
Posted on September 05, 2017 at 04:58

Hello, I use MDK-Lite 5.23 uVision / stm32F746BG. I work with two timer interrupts at the same moment: TIM1_UP_TIM10_IRQHandler(void) + TIM2_IRQHandler(void) + program code at the main() function 

void TIM1_UP_TIM10_IRQHandler(void)

{

  /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */

    /* USER CODE END TIM1_UP_TIM10_IRQn 0 */

  HAL_TIM_IRQHandler(&htim1);

  /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */

      HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_4);

  /* USER CODE END TIM1_UP_TIM10_IRQn 1 */

}

/**

* @brief This function handles TIM2 global interrupt.

*/

void TIM2_IRQHandler(void)

{

  /* USER CODE BEGIN TIM2_IRQn 0 */

  HAL_TIM_Base_Stop_IT(&htim2);

  /* USER CODE END TIM2_IRQn 0 */

  HAL_TIM_IRQHandler(&htim2);

  /* USER CODE BEGIN TIM2_IRQn 1 */

   HAL_GPIO_TogglePin(GPIOJ, GPIO_PIN_13);

  HAL_TIM_Base_Start_IT(&htim2);

  /* USER CODE END TIM2_IRQn 1 */

}

int main(void)

{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

  HAL_Init();

  /* Configure the system clock */

  SystemClock_Config();

  /* Initialize all configured peripherals */

  MX_GPIO_Init();

  MX_TIM2_Init();

  MX_TIM1_Init();

  /* Initialize interrupts */

  MX_NVIC_Init();

  /* USER CODE BEGIN 2 */

  HAL_TIM_Base_Start_IT(&htim1);

HAL_TIM_Base_Start_IT(&htim2);

   

  /* USER CODE END 2 */

  /* Infinite loop */

  /* USER CODE BEGIN WHILE */

  while (1)

  {

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  HAL_GPIO_TogglePin(GPIOJ, GPIO_PIN_14);

}

  /* USER CODE END 3 */

}

3 REPLIES 3
Yuriy Pankratz
Associate II
Posted on September 05, 2017 at 05:04

Question: why I get answer from TIMER1 only? (Not from TIM 2, Not from Main() function)

If I Stop TIM1: HAL_TIM_Base_Stop_IT(&htim1); 

then I get answer from TIM2  only and nothing from Main() function

what I have to do?

Please, help  me.

Yuriy Pankratz
Associate II
Posted on September 05, 2017 at 05:31

I got new events.

If I start TIM2 first like this HAL_TIM_Base_Start_IT(&htim2);

I get answer from TIM2.

If I start TIM1 first like this HAL_TIM_Base_Start_IT(&htim1);

I get answer from TIM1.

If I do not start TIM1 and do not start TIM2 I get answer from main () function.

Why?

Yuriy Pankratz
Associate II
Posted on September 13, 2017 at 11:39

Thanks. I understood my problem - it is too high frequency!!!

)))