完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我想得到比time0或Time1单独的时间更长的时间。我认为我可以通过使用Time0来控制Time1门,通过设置1GCONTITS。T1GSS= 0B01;我已经尝试了很多不同的设置,但似乎无法得到Time1计数与大门。有人能帮忙吗????谢谢!
以上来自于百度翻译 以下为原文 I wanted to get a longer time than what timer0 or timer1 can do alone. I thought that I could control the timer1 gate using timer0 by setting T1GCONbits.T1GSS = 0b01;. I have tried many different settings but can't seem to get Timer1 counting with the gate on. Could someone please help?!?! Thanks, //config timer 1 T1CONbits.T1CKPS = 0b00;//timer 1 prescale T1CONbits.TMR1CS = 0b00;//timer 1 clock source instruction clock(Fosc/4) OSCCONbits.IRCF = 0b0000;//31KHz, clock determined in configeration word 1 T1CONbits.TMR1ON = 1;//turn on timer1 T1GCONbits.TMR1GE = 1;//gate control T1GCONbits.T1GSS = 0b01;//gate source selection T1GCONbits.T1GTM = 1;//gate is in toggle mode, clear puts it into single pulse mode T1GCONbits.T1GSPM = 0;//single pulse mode T1GCONbits.T1GPOL = 0;//gate polarity T1CONbits.nT1SYNC = 1; //config timer 0 OPTION_REGbits.TMR0CS = 0;//timer 0 clock source internal instruction clock (Fosc/4)) OPTION_REGbits.PSA = 0;//Prescaler assigned to timer 0 OPTION_REGbits.PS = 0b000;//prescale 1:256 = 111 //Setup interrupts INTCONbits.GIE = 1;//enable all interrupts INTCONbits.PEIE = 1;//enable Peripheral interrupts (timer1, AD, Rx, Tx, LCD) INTCONbits.TMR0IE = 1;//timer0 interrupt 1 = enabled PIE1bits.TMR1IE = 1;//timer 1 interrupt void interrupt Interrupts(void){ if(INTCONbits.TMR0IF == 1 && INTCONbits.TMR0IE == 1){ //Timer 0 overflow INTCONbits.TMR0IF = 0;//clear the interrupt flag } if(PIR1bits.TMR1IF == 1){ //Timer 1 overflow PIR1bits.TMR1IF = 0;//reset the flag } } |
|
相关推荐
1个回答
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5140 浏览 9 评论
1988 浏览 8 评论
1917 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3159 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2215 浏览 5 评论
708浏览 1评论
598浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
480浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
609浏览 0评论
505浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-8 20:00 , Processed in 1.156333 second(s), Total 79, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号