我是靠谱客的博主 醉熏小兔子,这篇文章主要介绍11----GD32E103RBT6----基本定时器测试代码[测试不通过],现在分享给大家,希望可以做个参考。

bsp_basictim.h

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef __BSP_RCU_H #define __BSP_RCU_H #include "gd32e10x.h" #define BASIC_TIM_CLK RCU_TIMER5 #define BASIC_TIM TIMER5 #define BASIC_TIM_Period 1500 #define BASIC_TIM_Prescaler 59 #define BASIC_TIM_IRQ TIMER5_IRQn #endif

bsp_basictim.c

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "bsp_basictim.h" // 中断优先级配置 static void NVIC_Configuration(void) { nvic_priority_group_set(NVIC_PRIGROUP_PRE2_SUB2 ); nvic_irq_enable(BASIC_TIM_IRQ,1,1); } //配置计数器加到1000 void BASIC_TIM_Mode_Config(void) { timer_parameter_struct TIM_TimeBaseStructure; rcu_periph_clock_enable(BASIC_TIM_CLK); TIM_TimeBaseStructure.prescaler = BASIC_TIM_Prescaler; TIM_TimeBaseStructure.alignedmode = TIMER_COUNTER_EDGE; TIM_TimeBaseStructure.counterdirection = TIMER_COUNTER_UP; TIM_TimeBaseStructure.period = BASIC_TIM_Period; TIM_TimeBaseStructure.clockdivision = TIMER_CKDIV_DIV1; TIM_TimeBaseStructure.repetitioncounter = 0; timer_init(BASIC_TIM, &TIM_TimeBaseStructure); NVIC_Configuration(); timer_interrupt_enable(BASIC_TIM, TIMER_INT_UP); timer_enable(BASIC_TIM); }

main.c

复制代码
1
2
3
4
5
void test_basictim(void) { TP1_GPIO_Config(); BASIC_TIM_Mode_Config(); }

 

最后

以上就是醉熏小兔子最近收集整理的关于11----GD32E103RBT6----基本定时器测试代码[测试不通过]的全部内容,更多相关11----GD32E103RBT6----基本定时器测试代码[测试不通过]内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(63)

评论列表共有 0 条评论

立即
投稿
返回
顶部