完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我正在尝试使用32位定时器(2-3)在PIC24FJ128GA310,与FoSC=8兆赫。下面是我的代码,它没有给我10秒延迟”void timer32_Init(){T2CON=0x00;//停止任何16/32位Timer2操作T3CON=0x00;//停止任何16位Timer3操作TMR3=0x00;//清除timer3寄存器TMR2=0x00的内容;//清除timer2寄存器PR3=0xFFFF;//L将值0xFF PR2=0xFFFF;//用值0xFF IPC2bits.T3IP=0x01加载周期寄存器2;//设置Timer3中断以获得期望的优先级级别//(此示例指定级别1优先级)IFS0bits.T3IF=0;//清除Timer3中断状态标志IEC0bits.T3I。E=0;//启用Time3中断T2CONTITES。T32=1;//启用32位定时器操作T2CONBITS。吨=1;/ /启动带预分频器T2CONC=0x8038的32位定时器;//设置为1:1,时钟源设置为/ /内部指令周期}“”定义延迟-10秒156250 / /十秒延迟空间主(空){INTCTalp;CARR Re=='''′0′;int TimeLLSB=0,TimeMsMs==0;未签名的long TimeTMR32();UART2INITE();Time1GIN();TrcRe2初始化();PutsNuTART1(Buff,SaMPTF(Buff,“欢迎rn”));Delay1(),PuffsNuTAR1(Buff,Simulf(Buff)”ONT,x=0,y=4,z=3,i;无符号字符rn")))TMR3HLD=0;TMR3HLD=0;TMR3HLD=0;//重新启动计数TMR2=0;//重新启动计数TMR2=计数TMR2=0;//重新启动计数//TMR2/TMR2计数/TMR3HLD=0;//重新启动计数//TMRTMR3HLD计数//TMRTMR3HLD=0/TMR3HLD=2;///00X0000000002; //重新启动计数//重新启动计数//TMWHSW//TMWW//TMR2//TMR2//TMR2//TMR2//TMR2//TMR2//TMR2//TMR2_l***=TMR2;//Transfer t他将LSW转换为temp_l*** temp_m***=TMR3HLD;//将MSW从保持寄存器传输到temp_TMR32=temp_m****65536+temp_l***;}putsNUART1(buff,sprintf(buff,“hirn”)}“请帮助”。 以上来自于百度翻译 以下为原文 hi , I am trying to use 32 bit timer (2-3) in pic24fj128ga310, with Fosc = 8 MHz. Below is my code which is not giving me 10 sec delay " void Timer32_Init(){ T2CON = 0x00; //Stops any 16/32-bit Timer2 operation T3CON = 0x00; //Stops any 16-bit Timer3 operation TMR3 = 0x00; //Clear contents of the timer3 register TMR2 = 0x00; //Clear contents of the timer2 register PR3 = 0xFFFF; //Load the Period register3 with the value 0xFFFF PR2 = 0xFFFF; //Load the Period register2 with the value 0xFFFF IPC2bits.T3IP = 0x01; //Setup Timer3 interrupt for desired priority level //(this example assigns level 1 priority) IFS0bits.T3IF = 0; //Clear the Timer3 interrupt status flag IEC0bits.T3IE = 0; //Enable Timer3 interrupts T2CONbits.T32 = 1; //Enable 32-bit Timer operation T2CONbits.TON = 1; //Start 32-bit timer with prescaler T2CON = 0x8038; //settings at 1:1 and clock source set to //the internal instruction cycle } " " #define delay_10sec 156250 // ten sec delay void main(void) { int count,x=0,y=4,z=3,i; unsigned char temp; char arr2[] = {' |