stm32的pwm重映射管脚问题

pwm输出是玩航模的重要目标之一


问题描述

`之前学习的树莓派,最近又来到了Arm,手里有几块stm32f103c8t6的板子,放着也是浪费,就想用来学习使用一下!
主函数如下:

/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
#include "stm32f10x_tim.h"
#include "stm32f10x_rcc.h"
#include "tim3pwm.h"
void Delay(u32 count)
{
u32 i=0;
 for(;i<count;i++);
}
void RCC_Config(void) 
{
	 SystemInit(); //配置系统时钟为72M  
	
	RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOB,ENABLE ); /* GPIOB clock enable */
	RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM3,ENABLE );/* TIM3 clock enable */
	RCC_APB2PeriphClockCmd (RCC_APB2Periph_AFIO,ENABLE );
	//PB4,5用作定时器tim3的PWM输出引脚,要部分重映射配置,所以需要开启AFIO时钟。
		
}

void LED_GPIO_Config(void) 
{
  GPIO_InitTypeDef GPIO_InitStructure;
  GPIO_InitStructure.GPIO_Pin =GPIO_Pin_14| GPIO_Pin_15;//* 配置pb14,pb15可以作为刹车或正反用的控制端,带led可以显示控制状态 */	
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
   GPIO_SetBits(GPIOB, GPIO_Pin_14 | GPIO_Pin_15 );	 // 设置led关
	
//	GPIO_InitTypeDef GPIO_InitStructure;
//  **********RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE); // 使能PB端口时钟  
//  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15 ;	
//  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;       
//  GPIO_InitStructure
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值