一.在103的手册里可以看到每个io都有remap功能。
二.以TIMER1为例,PE13&PE14输出PWM波。
1.在用户手册的寄存器AFIO_REMAP1,可以看到不同IO口对应的remap功能配置:
2.代码示例:
int main(void)
{
GPIO_Config_T GPIO_ConfigStruct;
TMR_BaseConfig_T TMR_TimeBaseStruct;
TMR_OCConfig_T OCcongigStruct;
RCM_EnableAPB2PeriphClock((RCM_APB2_PERIPH_T)(RCM_APB2_PERIPH_GPIOE|RCM_APB2_PERIPH_AFIO|RCM_APB2_PERIPH_TMR1));
GPIO_ConfigPinRemap(GPIO_FULL_REMAP_TMR1);
GPIO_ConfigStruct.pin =GPIO_PIN_13|GPIO_PIN_14;
GPIO_ConfigStruct.mode = GPIO_MODE_AF_PP;
GPIO_ConfigStruct.speed = GPIO_SPEED_50MHz;
GPIO_Config(GPIOE, &GPIO_ConfigStruct);
TMR_TimeBaseStruct.clockDivision =TMR_CLOCK_DIV_1;
TMR_TimeBaseStruct.countMode =TMR_COUNTER_MODE_UP;
TMR_TimeBaseStruct.division = 71;
TMR_TimeBaseStruct.period = 999;
TMR_ConfigTimeBase(TMR1,&TMR_TimeBaseStruct);
OCcongigStruct.mode = TMR_OC_MODE_PWM1;
OCcongigStruct.outputState =TMR_OC_STATE_ENABLE;
OCcongigStruct.polarity = TMR_OC_POLARITY_HIGH;
OCcongigStruct.pulse = 300;
TMR_ConfigOC3(TMR1, &OCcongigStruct);
TMR_ConfigOC4(TMR1, &OCcongigStruct);
TMR_ConfigOC3Preload(TMR1,TMR_OC_PRELOAD_ENABLE);
TMR_ConfigOC4Preload(TMR1,TMR_OC_PRELOAD_ENABLE);
TMR_EnableAutoReload(TMR1);
TMR_Enable(TMR1);
TMR_EnablePWMOutputs(TMR1);
while(1)
{
}
}
以此类推...
|