本帖最后由 sn516952 于 2012-5-11 10:35 编辑
16F685的芯片.
void timer1_init(void)
{
T1CKPS1=0;
T1CKPS0=0;//00: 预分频1:1
TMR1IE = 1;//允许timer1溢出中断
TMR1H=0xF8; //赋值TMR1H
TMR1L=0x48; //赋值TMR1L 0xF848=1ms
TMR1CS = 0;//不与外部输入时钟同步
TMR1IF = 0;//溢出中断标志位.1=溢出.
//以下两行少了就不工作.
T0CS=0;//0= T0CS位清零选择定时器模式 内部指令周期时钟FOSC/4
T0IE=1;//1= 允许Timer0中断
TMR1ON =1;//使能timer1门控
TMR1IE=1;
GIE=1;//开总中断
}
偶然间发现
T0CS=0;//0= T0CS位清零选择定时器模式 内部指令周期时钟FOSC/4
T0IE=1;//1= 允许Timer0中断
timer1里面要加上这两句才工作. datasheet里也没有注明两个定时器有相关的地方.
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
you are basically not capable of thinking.
use your isr and flip two pins, one in the timer0's section and another in timer1's section and see the pins on a scope.
or to simulate, as I did below.
bad 16f685 tmrs.PNG (23.36 KB, 下载次数: 0)
下载附件
2012-5-12 19:17 上传
here, RC0 is being flipped in the timer0's "if" statement and RC1 is being flipped in the timer1's "if" statement.
一周热门 更多>