void PWM_3MHZ_Init( void )
{
RCC->APB2ENR |= RCC_APB2ENR_TIM15EN; //ʹÄܶ¨Ê±Æ÷15
RCC->AHBENR |= RCC_AHBENR_GPIOAEN; // ʹÄÜPIOA
GPIOA->MODER &= 0xFFFF0FFF; /* (3) */
GPIOA->MODER |= 0x0000A000; /* ÍÆÍìÊä³ö */
GPIOA->AFR[0] &= 0xFFFF00FF; //PA3 TIMER15_CH2 EN
TIM15->PSC = 47; /* (1) */
TIM15->ARR = 8; /* (2) */
TIM15->CCR1 = 4; /* (3) */
TIM15->CCMR1 |= TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1PE; /* (4) */
TIM15->CCER |= TIM_CCER_CC1E; /* (5) */
TIM15->CCR2 = 4; /* (3) */
TIM15->CCMR1 |= TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2PE; /* (4) */
TIM15->CCER |= TIM_CCER_CC2E; /* (5) */
TIM15->BDTR |= TIM_BDTR_MOE; /* (6) */
TIM15->CR1 |= 1<<7;
TIM15->CR1 |= TIM_CR1_CEN; /* (7) */
TIM15->EGR |= TIM_EGR_UG; /* (8) */
}
哪位看看还需要配置哪里。 |