PDA

View Full Version : DT-INTs Blinky Light question



circuitpro
- 4th February 2010, 17:01
Just trying to understand where the TMR1H and TMR1L registers are getting loaded to determine the time constant of the blinky light? This interrupt is based on an overflow, right? :confused:

Bruce
- 4th February 2010, 17:29
T1CON = $31 sets the prescaler to 8 and turns on timer1. The interrupt is on overflow.

Timer1 overflows in 8 * 65536 * 1uS if you're using a 4MHx oscillator.

circuitpro
- 4th February 2010, 18:03
So TMR1L & TMR1H aren't even used? Is it possible to increase the time without changing the oscillator frequency? In this case I'm using a 18F67J60 at 20Mhz, and it's just timing out too fast.

Bruce
- 4th February 2010, 18:30
This particular example doesn't reload TMR1L & TMR1H. It just lets timer1 count up to its max 16-bit value, then overflow.

A simple way to extend the time would be to increment a variable counter in the interrupt, then toggled the LED after X number of counts, and reset the count back to 0.

Or, on the 18F67J60, you could use timer0 in 16-bit mode with a prescaler of 1:256. That would give you >3 seconds until overflow.

circuitpro
- 4th February 2010, 18:49
OK. I'll start with incrementing a variable, and go from there. Theres a lot to learn with these timers.

Bruce
- 4th February 2010, 22:57
Theres a lot to learn with these timers.
They may seem a tad intimidating at first, but once you've played around with timers a bit, you might find them fairly easy.

But, the time you spend on learning timers is like a BB in a 55-gallon drum compared to the time & effort DT put into his instant interrupts.

Here's to Darrel...;o)

circuitpro
- 5th February 2010, 03:29
You're telling me! I've got a program going that's implemented 3 interrupts. I would have never believed it. I used to avoid interrupts at all costs. Darrel's routines make them so easy. Thanks Darrel!