我想配置PIC24F16KA102的Timer1来对其进行计数。时钟源必须是8 MHz的内部时钟。我配置了寄存器T1CON并在高电平上设置了TON位来启动定时器。 Timer1设置为每隔100 us进入一次溢出,然后在一段时间内我将增加可变计数。我不明白,因为timer1不起作用,我观察到它不会增加。为什么?PIC24F16KA102上的Timer1不工作
#include <xc.h>
#include "config.h"
int count = 0;
void main(void) {
TRISB = 0;
T1CON = 0; //TRM1 stopped, internal clock source, prescaler 1:1
_TON = 1;
TMR1 = 65135; //overflow of TM1 every 100 us (400 counts)
while (1) {
if (TMR1 == 65535) {
count++; // increase every 100 us
TMR1 = 65135;
}
}
}