PDA

View Full Version : PIC12f675 timer1 pulse width



ck1223
- 14th February 2006, 17:57
I'm trying to calculate a pulse width with the rfPIC12f675 using IOC. My pulse width will range from 3ms-7ms, and so i'm aiming to detect up to 4000 different values.

2 issues come into play.

1. (Most important issue) Timer1 is seperated into two 8bit addresses, TMR1H and TMR1L (i believe). Where TMR1H is the upper 8bits or the timer, and TMR1L is the lower 8bits of the timer. How can I "combine" these 2 addresses so that I can subtract the rising edge time from the falling edge time?

2. Using IOC, how can I check if the IOC went from low to high, than high to low on a specific port. I realize I can use GP2 for edge detecting setting for rise edge and falling edge, but I have 2 ports with incoming pulse widths, and thus have just decided to use IOC for both ports.

Darrel Taylor
- 15th February 2006, 04:05
Hi ck1223,

For the first issue ...
@TMR1 = TMR1L
TMR1 VAR WORD EXT
Now you can use the TMR1 value like any other word.

Just be sure to turn the timer OFF when changing values. Otherwise, the lowbyte might overflow into the highbyte in-between PBP changing the separate registers.
<br>