Translate

For those who have trouble with measuring time with micro controller !

When doing our digital electronics project I wanted to measure time using the PIC(16F877A)
Here it is explained in simple words

instruction clock cycle = clock cycle/4

The timer input clock(instruction clock) is passed to the prescalar and that is divided by preferred value and fed into timer register.

Say an interrupt occurs when value of timer(counter) becomes 256. Assume clock frequency is 20Mz.

As the timer input clock is instruction clock, we can say an interrupt occurs at the completion of every 256 input clock cycles.

As value fed to timer = instruction clock/prescalar value(say 8), we can say an interrupt occurs at the completion of every 256*8 instruction clock cycles.

As instruction clock = clock/4, an interrupt occurs at the completion of every 256*8*4 clock cycles.

So, the number of interrupts per second = 20Mz / (256*8*4)

INTERRUPTS_PER_SECOND = clock_frequency/(4 * prescalar_value * counter's(timer's) turnover value)

No comments:

Post a Comment