stm32 产生互补带死区pwm波,请问哪里出错了,仿真没结果呀
/**
******************************************************************************
* @file bsp_pwm_output.c
* @author
* @version V1.0
* @date 2016-xx-xx
* @brief tim1Êä³öһ·pwm bsp
******************************************************************************
* @attention
******************************************************************************
*/
#include "bsp_pwm_output.h"
static void TIM1_GPIO_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure2;
TIM_TimeBaseInitTypeDef TIM_TimeBasestructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_BDTRInitTypeDef TIM1_BDTRInitStructure;
/* ÉèÖÃTIM1CLK Ϊ 72MHZ */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
/* GPIOyA and GPIOB clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);
/*GPIOA Configuration: TIM1 channel 1 as alternate function push-pull */
GPIO_InitStructure2.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure2.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure2.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure2);
/*GPIOB Configuration: TIM1 channel 2 as alternate function push-pull */
GPIO_InitStructure2.GPIO_Pin = GPIO_Pin_13 ;
GPIO_Init(GPIOB, &GPIO_InitStructure2);
}
static void TIM1_Mode_Config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_BDTRInitTypeDef TIM1_BDTRInitStructure;
u16 CCR_Val =71;
TIM_TimeBaseStructure.TIM_Period =143;
TIM_TimeBaseStructure.TIM_Prescaler=0x0;
TIM_TimeBaseStructure.TIM_ClockDivision=0;
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_RepetitionCounter=0x0;
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_PWM2;
TIM_OCInitStructure.TIM_Pulse= CCR_Val;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_Low;
TIM_OCInitStructure.TIM_OutputState=TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OCNPolarity=TIM_OCNPolarity_Low;
TIM_OCInitStructure.TIM_OutputNState=TIM_OutputNState_Enable;
TIM_OCInitStructure.TIM_OCIdleState=TIM_OCIdleState_Reset;
TIM_OCInitStructure.TIM_OCNIdleState=TIM_OCNIdleState_Reset;
TIM_OC1Init(TIM1,&TIM_OCInitStructure);
TIM1_BDTRInitStructure.TIM_OSSRState = TIM_OSSRState_Enable;
TIM1_BDTRInitStructure.TIM_OSSIState = TIM_OSSIState_Enable;
TIM1_BDTRInitStructure.TIM_LOCKLevel = TIM_LOCKLevel_1;
TIM1_BDTRInitStructure.TIM_DeadTime = 0xc0;
TIM1_BDTRInitStructure.TIM_Break = TIM_Break_Disable;
TIM1_BDTRInitStructure.TIM_BreakPolarity = TIM_BreakPolarity_Low;
TIM1_BDTRInitStructure.TIM_AutomaticOutput = TIM_AutomaticOutput_Enable;
TIM_BDTRConfig(TIM1,&TIM1_BDTRInitStructure);
TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM1, ENABLE);
TIM_Cmd(TIM1,ENABLE);
TIM_CtrlPWMOutputs(TIM1, ENABLE);
TIM_ITConfig(TIM1, TIM_IT_Update , ENABLE);
}
void TIM1_PWM_Init(void)
{
TIM1_GPIO_Config();
TIM1_Mode_Config();
}
/*********************************************END OF FILE**********************/