Here's the basic of TIMER1
Timer1 is act as a back ground counter on RB6 pin on the PIC16F628. It store the result in TMR1L and TMR1H register.
So you need to:- 1. set TMR1L and TMR1H to 0, to make the counter begin count at 0.
2. start the counter By using T1CON=7
The above set timer to:- 1. No sychro from the internal to the internal clock [bit 2]
2. Use external RB6 as clock source [bit 1]
3. Enable timer1 [bit 0]
then after you just have to wait for the sampling time you want to use. Once it's finish. stop the timer with T1CON=0
Now your result is store into internal register TMR1L and TMR1H in two Byte format. Place them into one WORD variable and display your count
MyCount var word
MyCount.lowbyte=TMR1L
MyCount.HighByte=TMR1H
lcdout $FE,1,"MyCount",#Mycount
you can test if the TIMER1 has overflow by testing PIR1.0 If 0 then there's no overflow. If 1... TIMER1 has overflow.
If it has overflow, you must clear it by software PIR1.0=0
Last edited by mister_e; - 27th January 2005 at 19:47.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks