mirror of
https://github.com/EFeru/hoverboard-sideboard-hack-GD.git
synced 2025-07-27 17:49:32 +00:00
/*! \file readme.txt \brief description of the TIMERs cascade synchro demo */ /* Copyright (C) 2017 GigaDevice 2014-12-26, V1.0.0, platform GD32F1x0(x=3,5) 2016-01-15, V2.0.0, platform GD32F1x0(x=3,5,7,9) 2016-04-30, V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) 2017-06-19, V3.1.0, firmware update for GD32F1x0(x=3,5,7,9) */ This demo is based on the GD32150R-EVAL/GD32190R-EVAL board, it shows how to synchronize TIMER peripherals in cascade mode. In this example three timers are used: 1/TIMER1 is configured as master timer: - PWM mode is used - The TIMER1 update event is used as trigger output 2/TIMER2 is slave for TIMER1 and master for TIMER0, - PWM mode is used - The ITR0(TIMER1) is used as input trigger - External clock mode is used,the counter counts on the rising edges of the selected trigger. - The TIMER2 update event is used as trigger output. 3/TIMER0 is slave for TIMER2, - PWM mode is used - The ITR1(TIMER2) is used as input trigger - External clock mode is used,the counter counts on the rising edges of the selected trigger. The TIMERxCLK is fixed to 72 MHz, the TIMER1 counter clock is : 108MHz/3600 = 20 KHz. The master timer TIMER1 is running at TIMER1 frequency : TIMER1 frequency = (TIMER1 counter clock)/ (TIMER1 period + 1) = 5 Hz and the duty cycle = TIMER1_CH1CV/(TIMER1_CAR + 1) = 50% The TIMER2 is running: - At (TIMER1 frequency)/ (TIMER2 period + 1) = 2.5 Hz and a duty cycle equal to TIMER2_CH0CV/(TIMER2_CAR + 1) = 50% The TIMER0 is running: - At (TIMER2 frequency)/ (TIMER0 period + 1) = 1.25 Hz and a duty cycle equal to TIMER0_CH0CV/(TIMER0_CAR + 1) = 50% Connect the three pins to a logic analyzer to monitor the different waveforms: - TIMER1_CH1 pin (PB3) - TIMER2_CH0 pin (PA6) - TIMER0_CH0 pin (PA8)