Implementing two timers in PIC

Thread Starter

RG23

Joined Dec 6, 2010
304
I have defined the two timers in PIC16F887 as follows

#//////////////////////////////////////////////////////////////////////////////////

Doing the above code I am not able to implement the two timers correctly

If anyone has an idea please let me know

Thanks
 
Last edited:

Markd77

Joined Sep 7, 2009
2,806
Can we see the complete code? If you go advanced, select the code and click the # icon it looks better.
Have you set the Global interrupts Enable bit in INTCON?
 

THE_RB

Joined Feb 11, 2008
5,438
Why not use just one timer of 120uS, then generate the 2mS event after every 17 events of 120uS?

That just requires one 120uS timer, and one variable to count to 17. :)
 

mjhilger

Joined Feb 28, 2011
118
You didn't tell us your clock speed, but an int every 120uS is really pushing that little chip. You are not going to get much processing done outside your interrupt routine, and depending on what you are doing inside your routine, you might not be exiting before the next int. You know you have to clear the individual timer int flags as well as issue the RETI. Are you sure your timers are not running and maybe only executing the int routine only 1 time?

I like the 16F series, but the 18F is a bunch faster and could do this easier. I like the PIC18F4525 - also has a built in osc, so no external xtal needed (so with the internal 8Mhz and PLL set to 4x you get 32Mhz clk).
 
Top