From 82e38738a4d532cc3d56cbf80c1a4093f23cdd6a Mon Sep 17 00:00:00 2001 From: tao_z <tzj0429@163.com> Date: Wed, 14 Jul 2021 07:01:42 +0800 Subject: [PATCH] 调整时钟64MHz。 RTT任务增加马达开启和关闭功能 --- USR/SRC/pwm.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/USR/SRC/pwm.c b/USR/SRC/pwm.c index d51e789..e94f7f5 100644 --- a/USR/SRC/pwm.c +++ b/USR/SRC/pwm.c @@ -9,6 +9,7 @@ * */ #include "pwm.h" +#include "bldc_ctrl.h" static volatile uint32_t timer_outcnt = 0; /***************************************************************************************************** Timer2 is used to speed cal @@ -24,10 +25,10 @@ timer_deinit(TIMER2); - timercontralcfg.prescaler = 4799; //48Mhz /4800 =0.01Mhz = 100us + timercontralcfg.prescaler = TIMER2_PERIOD; //64Mhz /64 =1Mhz = 1us timercontralcfg.alignedmode = TIMER_COUNTER_EDGE; timercontralcfg.counterdirection = TIMER_COUNTER_UP; - timercontralcfg.period = PERIOD_CAP; //100us*10000=1s + timercontralcfg.period = PERIOD_CAP; //1us*30000=30ms timer_init(TIMER2, &timercontralcfg); timer_interrupt_flag_clear(TIMER2, TIMER_INT_UP); @@ -145,7 +146,11 @@ } extern void TIMER2_IRQHandler_CallBack(void) { - timer_outcnt++; + if (++timer_outcnt > SPEED_TIMEOUT) + { + //to do + set_bldcm_disable(); + } } extern uint32_t GetSpeedTimerOutcnt(void) -- Gitblit v1.8.0