主题中讨论的其他器件:TM4C123
全部降级:
我将 TIMER1B 设置为 PWM 模式;配置的其余部分是相同的、除非使用不同的边沿来捕捉中断更新周期和占空比、这种现象是不同的;
1、代码部分:PWM 周期值更改模式(ms):1 -> 2 -> 3 -> 4 -> 5 - 4 -> 3 -> 2 > 1 -> 2 ... ;占空比:50%
/*定时器配置*/
GPIOPinConfigure (GPIO_PL6_T1CCP0);
GPIOPinConfigure (GPIO_PL7_T1CCP1);
GPIOPinTypeTimer (GPIO_PORTL_base、GPIO_PIN_6|GPIO_PIN_7);
TimerConfigure (Timer1_base、 Timer_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM|TIMER_CFG_B_PWM);
HWREG (Timer1_base + TIMER_O_TBMR)|=0x00000500;//在下一次超时更新。
TimerControlLevel (Timer1_base、timer_B、0);
TimerControlEvent (Timer1_base、timer_B、timer_event_POS_EDGE);//timer_event_NEG_EDGE);
{InterIntClear (Timer1_base、timer_CAPB_event);TimerIntEnable (Timer1_base、timer_CAPB_event);IntEnable (INT_TIMER1B);// timerStart */ TimerLoadSet (Timer1_base、timer_B、120000 & 0xFFFF);// 1ms TimerSet (Timerb_delay)、Timerbt (0x00_delay 1)、Timerbay Timerbt (Timerbay)、Timerb_timerbt (Timerb_delay)、Timerbt (Timerbay 1)、Timerbay Timerbt (timerbay 1)、Timerbay Timerbay 1、Timerbt (timerbay Timerbay 1)、Timerbay Timerb_timerbay 1、Timerb_timerbay 1、Timerbt (timerb_timerbay)、Timerbay Tim
静态 uint32_t 周期= 120000;// 1ms
静态 uint32_t Duty = 0;
静态 uint8_t inc_flag = 1;
// printf ("timer1B int\n");
如果(inc_flag)
{
期间+= 120000;
如果(周期>= 600000)
{
INC_FLAG = 0;
}
}
其他
{
期间-= 120000;
如果(周期<= 120000)
{
INC_FLAG = 1;
}
}
占空比=周期>> 1;
TimerLoadSet (Timer1_base、timer_B、Period&0xFFFF); //周期
TimerPrescaleSet (Timer1_base、Timer_B、(周期>> 16)&0xFF);
TimerMatchSet (Timer1_base、timer_B、Duty 和0xFFFF); //占空比
TimerPrescaleMatchSet (Timer1_base、Timer_B、(占空比>> 16)&0xFF);
// TimerIntClear (Timer1_base、timer_TIMB_TIMEOUT);
TimerIntClear (Timer1_base、timer_CAPB_event);
}





