//set PB0 as AF function
GPIOB->MODER |=(CHN_MODE<<(2*0)); //AF function
GPIOB->OSPEEDR |=(3<<(2*0));
#if CHN_MODE==2
GPIOB->PUPDR |=(2<<(2*0));
GPIOB->AFR[0] |=(2<<(4*0)); //AF2-TIM1_CH2N
#endif
//set PB1 as AF function
GPIOB->MODER |=(CHN_MODE<<(2*1)); //AF function
GPIOB->OSPEEDR |=(3<<(2*1));
#if CHN_MODE==2
GPIOB->PUPDR |=(2<<(2*1));
GPIOB->AFR[0] |=(2<<(4*1)); //AF2-TIM1_CH3N
#endif
//打开TIM1的时钟
RCC->APB2ENR |=RCC_APB2ENR_TIM1EN;
/* Time 定时基础设置*/
TIM1->CR1 =(0<<8); //clock division
TIM1->CR1 |=(0<<5); //0-边沿对齐,1-中心对齐1
//预分频
TIM1->PSC =0;
/****** 重复频率 */
TIM1->ARR=ARR_DATA;
/* Set the Repetition Counter value */
TIM1->RCR = 0;