'board_android-IoT/STM32F'에 해당되는 글 31건
- 2022.10.12 :: STM32F Timer2 (TIM2) Init and run
board_android-IoT/STM32F
2022. 10. 12. 16:05
- TIM2
> 사용하는 보드는 STM32F103계열로 72Mhz사용함.
>>.3. stm32f1xx_it.c
/** * @brief This function handles TIM2 global interrupt. */ void TIM2_IRQHandler(void) { /* USER CODE BEGIN TIM2_IRQn 0 */ /* USER CODE END TIM2_IRQn 0 */ HAL_TIM_IRQHandler(&htim2); /* USER CODE BEGIN TIM2_IRQn 1 */ //============================================ // 100uSec timer static int n_Timer1Interrupt = 0; GPS.usec++; GetHandyPhase(); Make60Hz(); if(++n_Timer1Interrupt > (T1COUNTER4SEC-1)) { n_Timer1Interrupt = 0; INS.timemarkon = ON; // BUZZ status toggle for debugging GPIOE->ODR ^= GPIO_PIN_0 ; //debug , 20220902 , 20221012 , BUZZ , PE0 , } // HAL_GPIO_TogglePin(TP7_GPIO_Port, TP7_Pin); /* USER CODE END TIM2_IRQn 1 */ } |
>>.2. main.c/main()에서 아래 함수 호출하여 htim2 활성화(시작)한다
HAL_TIM_Base_Start_IT(&htim2);
>>.1. TIM2 초기화 (main.c)
/* TIM2 init function */ static void MX_TIM2_Init(void) { TIM_ClockConfigTypeDef sClockSourceConfig; TIM_MasterConfigTypeDef sMasterConfig; htim2.Instance = TIM2; htim2.Init.Prescaler = 72; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 99; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim2) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } } |
https://blog.naver.com/eziya76/221451890046
[STM32 HAL] Timer# Basic 타이머
Reference: Mastering STM32 by Carmine Noviello ** 자료 해석에 오류가 있을 수 있습니다 ** [배...
blog.naver.com
'board_android-IoT > STM32F' 카테고리의 다른 글
STM32F103CBT6(128KB Flash) user flash write (1) | 2023.10.26 |
---|---|
Target is not responding, retrying (0) | 2023.10.21 |
Keypad double click detect (0) | 2023.10.11 |
convert usb serial port to bluetooth communication (0) | 2023.04.01 |
STM32F107 외부 인터럽트 (0) | 2023.01.11 |