/**************************************************************************
* 函数名:Tim2_Time_Upmode_conf
* 描述 :TIM2定时器功能初始化
* 输入 :uint8_t TIM2_Prescaler 只能是2的N次幂 1,2,4,8
uint16_t TIM2_Period 1~65535
*
* 输出 :无
* 返回 :无
* 调用 :外部调用
*************************************************************************/
void Tim2_Time_Upmode_conf(uint8_t TIM2_Prescaler,uint16_t TIM2_Period)
{
TIM2_PSCR = (uint8_t)(TIM2_Prescaler);
/* Set the Autoreload value */
TIM2_ARRH = (uint8_t)(TIM2_Period >> 8);
TIM2_ARRL = (uint8_t)(TIM2_Period);
/* Set or reset the UG Bit */
TIM2_EGR = (uint8_t)TIM2_PSCRELOADMODE_IMMEDIATE;
/*!< Auto-Reload Preload Enable mask. */
TIM2_CR1 |= (uint8_t)MASK_TIM2_CR1_ARPE;
/* Enable the Interrupt sources */
TIM2_IER |= (uint8_t)TIM2_IT_UPDATE;
/*!< Counter Enable mask. */
TIM2_CR1 |= (uint8_t)MASK_TIM2_CR1_CEN;
}
|