如下程序有哪里写的不对吗?求指教.输不出PWM信号
#include "stm32f10x.h"
int main()
{
GPIO_InitTypeDef my_GPIOA; //my_GPIOA是结构体变量
TIM_TimeBaseInitTypeDef my_timer_base_init;
TIM_OCInitTypeDef my_timer_oc;
//配置GPIO
my_GPIOA.GPIO_Pin=GPIO_Pin_7;
my_GPIOA.GPIO_Speed=GPIO_Speed_50MHz;
my_GPIOA.GPIO_Mode=GPIO_Mode_AF_PP;//复用推挽输出
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE);//开启GPIOA和GPIO复用
GPIO_Init(GPIOA,&my_GPIOA);
//配置TIMER3
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);
TIM_DeInit(TIM3);
TIM_InternalClockConfig(TIM3); //使用内部时钟
my_timer_base_init.TIM_Prescaler=2;
my_timer_base_init.TIM_CounterMode=TIM_CounterMode_Up;
my_timer_base_init.TIM_Period=1000-1;
my_timer_base_init.TIM_ClockDivision=0;
TIM_TimeBaseInit(TIM3,&my_timer_base_init);
//配置TIMER3的PWM
my_timer_oc.TIM_OCMode=TIM_OCMode_PWM1;
my_timer_oc.TIM_Pulse=100;
my_timer_oc.TIM_OCPolarity=TIM_OCPolarity_High;
my_timer_oc.TIM_OutputState=TIM_OutputState_Enable;
TIM_OC2Init(TIM3,&my_timer_oc);//通道2输出
TIM_Cmd(TIM3,ENABLE);
while(1);
}
|