Page 1 of 1

setting counters with timers

PostPosted: Thu Nov 20, 2014 5:16 am
by eagle1
hi,

how to set a counter to count times of processes

should i set TIMER0 as a counter when counting and as a timer when calling delays ?


i set a counter >> then decfsz to count no. of times and it did not work

Re: setting counters with timers

PostPosted: Fri Nov 21, 2014 2:40 am
by AussieSusan
I must admit I'm not sure what you are trying to achieve or on what device - different devices have differing peripherals and differing ways of doing things.
If you are wanting to count the number of cycles between to events in your program, then I would initialise the timer to 0 and then start it (assuming it is one that counts up), do whatever needs timing and then stop the timer and look at the count.
If you want to count the time between 2 external events then the input compare peripheral may be better or a gated timer if such exist on your device.
Susan

Re: setting counters with timers

PostPosted: Fri Nov 21, 2014 9:19 am
by ric
As always, if you tried something, and it didn't work as you expected, then SHOW THE CODE.
Just describing what you wanted to code to do doesn't help, we need to see the actual code.