This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294利用定时器产生PWM波问题



TM4C1294中利用定时器产生频率为1KHz的PWM波,利用的是在中断中进行计数,一共计1000个数,占空比自己控制。如下所示,duty=0.8,即80%的占空比

void Timer0IntHandler(void)
{
timercount++;
ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
if(timercount<=1000*duty)
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 1);
}
else
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0);
if(timercount==1000) timercount=0;
}
ROM_IntMasterDisable();
ROM_IntMasterEnable();
}

所以为需1us进一次终端,我的计时器设置是这样的:

 ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, 120000/Frequency);

这上面Frequency=1000,;但是得到的波形是周期为4ms的周期;当我设置Frequency=100时,周期是10ms,正常的。

这是什么原因?