Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Timer Calculation

Status
Not open for further replies.

2camjohn

Member
I am trying to set up the timer for a PIC16f629

I think I am missing something in my calculation.


I am running at 4mhz, so each cycle takes 0.00000025 seconds

The prescalar is at 255 (111) so that means there is an interrupt every 0.000064 seconds.

Does that seem right to you?
Because it seems slightly small to me?
Anyone have any tips on using the timers?

Thanks
John
 
The timers run on Fosc/4. so with a 4Mhz crystal they only get 1000 000 counts / sec.

And every time the prescaler rolls over, the timer register gets one tick. Once the timer register rolls over you get an interrupt.
 
OK so...



I am running at 4mhz, so each cycle takes 0.00000025 seconds
A timer running on FOSC/4 will count every 0.000001 seconds


The timer increments after 256 counts which is every 0.000256 seconds.

And we get an interrupt when the timer overflows its 8 bits (another 256) which is every 0.065536 seconds.

That seems better to me.

Is it correct?

Thanks
John
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top