PLL operation
Christofer A
Posts: 9
Hello,
I'm wondering if anyone have some good explaining examples for PLL operation. I have some trouble to understand the ctrmode I have to set and how they work.
I what to continuously measure the time a pin is high, using PLL. If possible using an overflow function to a second register, so I can preset the overflow time. So each count in the second register is equivalent to a certain time ex. 1ms. So each time I read the second register I can see how many ms the pin has been high.
Any examples would be greatly appreciated.
Thanks in advance.
Christofer A.
I'm wondering if anyone have some good explaining examples for PLL operation. I have some trouble to understand the ctrmode I have to set and how they work.
I what to continuously measure the time a pin is high, using PLL. If possible using an overflow function to a second register, so I can preset the overflow time. So each count in the second register is equivalent to a certain time ex. 1ms. So each time I read the second register I can see how many ms the pin has been high.
Any examples would be greatly appreciated.
Thanks in advance.
Christofer A.
Comments
The hardware counters always count by the system clock. The PLL is only used to generate outputs, you cannot "count" at a PLL output clock rate.
It sounds like you just need to set the counter to "count when pin is high" mode, then divide the phs value to (system_clock / 1000) to get milliseconds, then reset phs to zero.
Are you using spin or PASM ?
I would do something like:
setup counter
wait for pin to go high
wait for pin to go low
DO
set phsx to zero
wait for pin to high
wait for pin to go low
read phsx and divide to get milliseconds
LOOP
I hope this helps,
Bean
are good; I looked at one to measure Tach on a vehicle. Using assembly, I have found,
will involve more than one would think on the onset. The execution times of the assembly
commands take clock ticks, which take away from measurement. This is relative, because
you are running at clock speeds of 5 - 20 Mhz, which gives a good time "resolution", in
respect to the lower frequency you are looking for. Missing a few pulses does not seem to
make a difference, because of the speed.
Thanks for the input. I'm using PASM and will try to set up ctrmode %01000 POS detector, will get back after some testing.
//Christofer