|
自助者方得神助,终于搞定了
--------------设置------------------------ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3, ENABLE);
// Time base configuration TIM_TimeBaseStructure.TIM_Period = 0xFFFF; TIM_TimeBaseStructure.TIM_Prescaler = 0x00; TIM_TimeBaseStructure.TIM_ClockDivision = 0x0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_ETRClockMode2Config(TIM2, TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0); --------------测试---------------------------------------
TIM_SetCounter(TIM2, 0); TIM_Cmd(TIM2, ENABLE);
for(i=0;i<0xA000;i++) { nRes = TIM_GetCounter(TIM2); GPIO_SetBits(GPIOD, GPIO_Pin_0); Delay(1); GPIO_ResetBits(GPIOD, GPIO_Pin_0); Delay(1); } |
|