Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Timer 2 Interrupt with 10 MHz

Status
Not open for further replies.

albus

Junior Member level 2
Joined
Dec 26, 2010
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,458
I think this is an easy question but how can I set the interrupt to every 40 ms with 10 MHz crystal? I'm using PIC16F877.

I couldn't figure out the prescalar and postscalar. If everyone of them would be their maximum value which is 16, 255, 16. It would be equal to 26 ms or so I guess?

Code:
setup_timer_2( T2_DIV_BY_x, y, z);
 

u can check that by changing the status of an output pin(and resetting timer value on every interrupt) and checking its frequency on CRO or frequency counter.....n fine tune your values..

instruction cycle is osc/4....so urs will be 2.5MHz...
time period = 1/2.5MHz = 0.4us
 

I know that time period is 0.4 us. But even if I set every value to its maximum I can't possibly get 40 ms interrupt.

0.4*16*256*16=26.21 ms

I couldn't totally understand how to use timer_1, since it would be easier to do this with 16 bit timer. Bytheway I want to count every second, is it better practice to get 125(8 ms) interrupts in one second, or say 10 interrupts(100ms) in one second? Which would be more accurate, there will be bunch of other stuff going on in the pic?
 

ok you also have a problem with max count.....

so u have three options...
1. decrease the crystal frequency...
2. call another timer on first timers interrupt.. (i.e use two 8 bit timers)
3. use one 16 bit timer with 1:256 prescale.... ;) (best option if frequency of 10MHz is critical)

- - - Updated - - -

look man first of all your aim is not clear to me, what you want to do exactly so clearly state what you want to do....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top