|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2012-9-26 22:55:58
|
显示全部楼层
TIM7的配置:
void TIM_Config(void)
{
/* -----------------------------------------------------------------------
TIM3 Configuration: Output Compare Timing Mode:
In this example TIM3 input clock (TIM3CLK) is set to 2 * APB1 clock (PCLK1),
since APB1 prescaler is different from 1.
PCLK1 = HCLK / 4
TIM3CLK = 2 * PCLK1 => TIM3CLK = HCLK / 2 = SystemCoreClock /2=84 MHz
if want To get TIM3 counter clock at 50 MHz, the prescaler is computed as follows:
Prescaler = (TIM3CLK / TIM3 counter clock) - 1
Prescaler = ((SystemCoreClock /2) /50 MHz) - 1
----------------------------------------------------------------------- */
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM7, ENABLE);
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 30000;
TIM_TimeBaseStructure.TIM_Prescaler = 0 ;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM7, &TIM_TimeBaseStructure);
/* TIM Interrupts enable */
TIM_ITConfig(TIM7, TIM_IT_Update, ENABLE);
TIM_Cmd(TIM7, ENABLE);
} |
|