MG32F10x Standard Peripherals Firmware Library
|
*************** (C) COPYRIGHT 2020 - 2023 megawin Technology *************** * @file TIM/TIM_ExtTrigger_Synchro/readme.txt * @author megawin Application Team * @version V0.1.10 * @date 05-January-2023 * @brief Description of the TIM_ExtTrigger_Synchro example. ****************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE * TIME. AS A RESULT, MEGAWIN SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM * THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. ******************************************************************************
This example shows how to synchronize TIM peripherals with external triggers in cascade mode.
The system clock works at 96Mhz and is generated through PLL configuration. The PLL clock source is an external 8Mhz crystal oscillator. The frequency division ratio of APB1 is 1, and the frequency division ratio of APB2 is 1.
In this example, three timers are used:
1/TIM1 is configured as the main timer:
-Toggle Mode is used
-TIM1 ENABLE event used as trigger output
2/TIM1 is configured as Slave Timer for an external Trigger connected to TIM1.
TI2 pin (TIM1 CH2 configured as input pin):
-The TIM1 TI2FP2 is used as Trigger Input
-Rising edge is used to start and stop the TIM1: Gated Mode.
3/TIM3 is slave for TIM1 and Master for TIM4,
-Toggle Mode is used
-The ITR1(TIM1) is used as input trigger
-Gated mode is used, so start and stop of slave counter are controlled by the Master trigger output signal(TIM1 enable event).
-The TIM3 enable event is used as Trigger Output.
4/TIM4 is slave for TIM3,
-Toggle Mode is used
-The ITR2(TIM3) is used as input trigger
-Gated mode is used, so start and stop of slave counter are controlled by the Master trigger output signal(TIM3 enable event).
The running time of the three timers is:
TIMx frequency=TIMx lock counter /(TIMx_perio + 1)= 732.2Hz。
The starts and stops of the TIM1 counters are controlled by the external trigger.
The TIM3 starts and stops are controlled by the TIM1, and the TIM4 starts and stops are controlled by the TIM3.
In order to make the program work, you must do the following :
Run the example