新手入门
- 积分
- 31
- 金钱
- 31
- 注册时间
- 2015-8-25
- 在线时间
- 0 小时
|
5金钱
void Tim1_OC_Init()
{
TIM1_DeInit();
/*
TIM1_Period = 50000
TIM1_Prescaler = 0
TIM1_CounterMode = TIM1_COUNTERMODE_UP
TIM1_RepetitionCounter = 0
*/
TIM1_TimeBaseInit(23, TIM1_COUNTERMODE_UP, 49999, 0);
/*
TIM1_OCMode = TIM1_OCMODE_TOGGLE TIM1_CCRx=TIM1_CNT时,翻转OCxREF电平
TIM1_OutputState = TIM1_OUTPUTSTATE_ENABLE
TIM1_OutputNState = TIM1_OUTPUTNSTATE_DISABLE
TIM1_Pulse = 5000
TIM1_OCPolarity = TIM1_OCPOLARITY_LOW
TIM1_OCNPolarity = TIM1_OCNPOLARITY_HIGH
TIM1_OCIdleState = TIM1_OCIDLESTATE_SET
TIM1_OCNIdleState = TIM1_OCIDLESTATE_RESET
*/
TIM1_OC3Init(TIM1_OCMODE_INACTIVE, TIM1_OUTPUTSTATE_ENABLE, TIM1_OUTPUTNSTATE_DISABLE, 4999, TIM1_OCPOLARITY_LOW, TIM1_OCNPOLARITY_HIGH, TIM1_OCIDLESTATE_SET, TIM1_OCNIDLESTATE_SET);
TIM1_ITConfig(TIM1_IT_CC3, ENABLE);
/* TIM1 counter 使能 */
TIM1_Cmd(ENABLE);
TIM1_CtrlPWMOutputs(ENABLE); /* 使能TIM1输出 */
}
------------------------------------------中断函数------------------------------------
INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
{
TIM1_ClearITPendingBit(TIM1_IT_CC3);
LED_Reverse(LED_2);
}
|
|