STM32F407输入捕获-拨开云雾见青天

之前只用过51单片机,编程的时候全是设定寄存器,现在接触STM32发现寄存器太多了,头大了三天。。。
之前一直对着103的资料设定407的定时器,但是这哥俩区别真是有的,一开始就进错了门,还想找对人?407输入捕获要把GPIO设定成复用模式,还要做管脚复用的映射,
`GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_TIM5);  `
进入`GPIO_PinAFConfig` 看看注释后才豁然开朗,原来要这么设置AF。

@brief Changes the mapping of the specified pin.
@param GPIOx: where x can be (A..I) to select the GPIO peripheral.
@param GPIO_PinSource: specifies the pin for the Alternate function.
This parameter can be GPIO_PinSourcex where x can be (0..15).
@param GPIO_AFSelection: selects the pin to used as Alternate function.
This parameter can be one of the following values:
@arg GPIO_AF_RTC_50Hz: Connect RTC_50Hz pin to AF0 (default after reset)
@arg GPIO_AF_MCO: Connect MCO pin (MCO1 and MCO2) to AF0 (default after reset)
@arg GPIO_AF_TAMPER: Connect TAMPER pins (TAMPER_1 and TAMPER_2) to AF0 (default after reset)
@arg GPIO_AF_SWJ: Connect SWJ pins (SWD and JTAG)to AF0 (default after reset)
@arg GPIO_AF_TRACE: Connect TRACE pins to AF0 (default after reset)
@arg GPIO_AF_TIM1: Connect TIM1 pins to AF1
@arg GPIO_AF_TIM2: Connect TIM2 pins to AF1
@arg GPIO_AF_TIM3: Connect TIM3 pins to AF2
@arg GPIO_AF_TIM4: Connect TIM4 pins to AF2
@arg GPIO_AF_TIM5: Connect TIM5 pins to AF2

顺便记下捕

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值