近期用407 做个采样,一个利用定时器产生PWM输出, 再利用另外一个TIMER的外部触发模式2进行计数,在网上搜索了大批代码,各种尝试,CNT值始终不能计数,(有时候计数也是错误
[mw_shl_code=c,true] {
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOH clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
/* GPIOH Configuration: PH12 -> TIM3 CH3 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;//GPIO_Pin_0|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
//
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure ;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE) ;
TIM_DeInit( TIM2 ) ;
/* Time Base configuration */
TIM_TimeBaseStructure.TIM_Period = 0XFFFF; //
TIM_TimeBaseStructure.TIM_Prescaler = 1;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x5500;
TIM2->CR1&=~(u16)(0x3<<5); //边沿对齐方式
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
/* TIM1-ETR Configuration */
TIM_ETRClockMode2Config (TIM2,TIM_ExtTRGPSC_OFF,TIM_ExtTRGPolarity_NonInverted,0);
// TIM_SelectSlaveMode(TIM2,TIM_SlaveMode_External1);
[/mw_shl_code]
的,可能配置不对)求各位大神降临,@原子哥
407 是不是和STM32F103系列有差别,有用407 做成功的么,现在已经怀疑人生了  
 
|