Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to stop the Counter mode is Timer 1 in the PIC16F877

Status
Not open for further replies.

lythanhthuan

Member level 3
Joined
May 18, 2006
Messages
67
Helped
6
Reputation
14
Reaction score
3
Trophy points
1,288
Location
M.T.A-VN
Activity points
1,718
I am using the Timer 1 in the PIC16F877. I know that the timer 1 has 2 modes -

1. Timer mode
2. Counter mode

and this can be choosen by setting or clearing the TOCS bit.

However when i choose the counter mode this what i want to accomplish -

1. I was to start counting
2. Then switch off the counter mode
3. Save the current value in the counter and store it in any random register.
4. When we switch off the Counter mode I do not want the Timer mode to come in effect.

Any ideas are welcomed.
 

a timer is driven by the THE count


the rest is your dilema

samples of the count??

samples of the new count - old count * time = total time since

simply sample the timer
and use some maths to get your outcomes and further event effectors

you sample the timer then switch it off

or why switch it off

use an interrupt that when it detects a level
interrupts and samples then resets the timer

use c code for this its better...
and more compact
 

Hi,
1. Select required prescaler and load T1CON with ur configuration required
2. Set TMR1CS bit in T1CON for selecting External clock, this to configure TIMER1 as counter
3. Clear TMR1H and TMR1L registers
4. Set TMR1ON bit to start counting
5. To stop counting, clear TMR1ON bit. Timer will not start.
6. Read the count from registers TMR1H and TMR1L and store it to ur registers

If u want to count again perform operations from step 3

Thanks.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top