大家好,我最近在调PIC24FJ定时器,发现我往PR1寄存器写数,它是递减的,可是datasheet中写的是递增的,是不是哪里没有设置对?
下面是初始化程序:
void Timer1_Initialize(void)
{
T1CONbits.TCKPS1 = 0; //Timer1 Input Clock Prescale
T1CONbits.TCKPS0 = 0; //Timer1 Input Clock Prescale
T1CONbits.TCS = 1; //External clock from T1CK pin
//T1CONbits.TSYNC =1;
PR1 = 0x140; //10ms 这里如果我写0x140的话,中断函数中的IO 10ms会改变一次状态
//PR1 = 0x280; //20ms 如果写成0x280 ,中断函数中的IO 20ms会改变一次状态
T1CONbits.TSIDL = 0; //Discontinue module operation when device enters Idle mode
IEC0bits.T1IE = 1; //set the interrupt enable bit
T1CONbits.TON = 1; //Starts 16-bit Timer1
}
中断函数:
void __attribute__((__interrupt__, auto_psv)) _T1Interrupt(void)
{
IFS0bits.T1IF = 0;
LATFbits.LATF3 = ~(LATFbits.LATF3);
}
单片机型号是PIC24FJ256DA210 编译器 C30 用的是外部晶振32.768kHZ
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
you have a pic24f made by somebody else. :)
that should work.
make sure that you have turned on sosc in the configuration words.
晶振的配置位,我已经更改过,并且已经测试过波形,我相信,晶振的配置位是没有问题的
原来是这样,谢谢你
一周热门 更多>