GD32VF103 Timers are also different , Divided into several types : Advanced timer (TIMER0), Universal timer L0(TIMER1,2,3,4), basic timer (TIMER5,6)

Different types of fixed The specific functions of timers are different . There are still many functions .-&_&-

#include "timer.h" #include "gd32vf103.h" #include "gd32vf103_libopt.h"
#include "led.h" //
// //TIMER0 Basic timing initialization void TIMER0_Init() { timer_parameter_struct timer_initpara;
// Timer structure rcu_periph_clock_enable(RCU_TIMER0); // Enable TIMER0 Clock
timer_deinit(TIMER0); timer_struct_para_init(&timer_initpara); // Change structure parameters to initial values
timer_initpara.prescaler = 10799; // prescale timer_initpara.alignedmode =
TIMER_COUNTER_EDGE; // Align mode timer_initpara.counterdirection = TIMER_COUNTER_UP;
// Counting direction timer_initpara.period = 9999; // cycle timer_initpara.clockdivision =
TIMER_CKDIV_DIV4; // clock division timer_initpara.repetitioncounter = 0; // Repeat counter
timer_init(TIMER0, &timer_initpara);
timer_interrupt_enable(TIMER0,TIMER_INT_UP); // Enable update interrupt
eclic_irq_enable(TIMER0_UP_IRQn,2,0); // Enable medium break timer_enable(TIMER0); } //
// //TIMER0 Interrupt service function uint8_t TIMER0_i = 0; void TIMER0_UP_IRQHandler(void) {
if(timer_interrupt_flag_get(TIMER0, TIMER_INT_FLAG_UP) != RESET) // Receive interrupt {
timer_interrupt_flag_clear(TIMER0, TIMER_INT_FLAG_UP); // Clear interrupt flag bit TIMER0_i++;
printf("TIMER0 Update interrupt trigger -->> %d \n\r",TIMER0_i); } }
#ifndef __TIMER_H__ #define __TIMER_H__ #include "gd32vf103.h" #include
"systick.h" #include "stdio.h" #include "string.h" //
// // Function body declaration void TIMER0_Init(void); void TIMER0_UP_IRQHandler(void); #endif
#include "gd32vf103.h" #include "gd32vf103c_start.h" #include "systick.h"
#include <stdio.h> #include <string.h> #include "led.h" #include "key.h"
#include "usart0.h" #include "timer.h" //
// // Main function int main(void) { uint8_t key = 0; eclic_global_interrupt_enable();
eclic_priority_group_set(ECLIC_PRIGROUP_LEVEL3_PRIO1); LED_Init(); //LED Lamp initialization
KEY_Init(); //KEY Key initialization USART0_Init(); //USART0 initialization TIMER0_Init(); //TIMER0 initialization
printf(" Serial port test USART TEST 0123456789 \n\r"); while(1) { key = KEY_Scan(); if(key
== 1) {printf(" Press the key LED reversal \n\r");} } }
Personal opinion , Thanks for reading .

©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?