Timer1 -- chanA and chanB -- solved

When you want an interrupt on output compare, the timer count is compared to the value in OCR1A (or OCR1B). I don't understand how the two 16-bit registers are used. Seems like there should only be one.

I need to have an interrupt call 16 msec after a particular event. Seems like I would just load OCR1A with the appropriate count, prescale the counter and enable the interrupt.

Dr Q

I need to have an interrupt call 16 msec after a particular event

While, meanwhile, the Arduino is doing what?

The Arduino is running a light controller. It's really not going to do anything in that 16 msec--too little time for a second stroke on a light switch. However, the interrupt is designed to look for upsets to the GPIO (PCA9555) from EMI. It resets the GPIO chip and rewrites the last light configuration. 16 msec is approximately one 60 Hz cycle, top ensure that if there is an upset when a circuit is turned off or on, that the reset isn't accomplished prior to the upset. I don't want the GPIO to be reset and written to on every loop through the software as the Arduino looks for a switch push.

It would be easy to insert a delay(16) in the code, but there is a timing issue in case there is a double click input--the 16 msec is a non-trivial portion of the timing for a double click (which could also be taken into account) but I want the clean elegance of an interrupt to service this reset.

Dr. Q

Section 15.2.2 of the data sheet says that they are two 8-bit registers. Timer/Counter1 treats them as a single 16-bit register in certains cases. While the data sheet is fairly large (over 600 pages), do a search on OCR1A and you will likely find the type of information you need to solve your problem.

Not according to page 135 of the 660 page data "sheet." In paragraphs 16.11.15 and 16.11.6 it clearly shows two 16-bit registers at byte addresses 0x88, 0x89, 0x8A, and 0x8B. The higher addresses are for OCR1B.

Section 15 is for the 8-bit Timer0. I'm referring to Timer1, since it's the most available timer (not used by Arduino core routines, except for motor control).

Dr. Q

The original question was, what’s the register A-B difference? How are they used when doing a timer compare interrupt? Can you just leave B at zero and pretend it doesn’t interact?

Dr. Q

My bad…I was looking at TImer/Counter0.

I'm sure you've read it, but section 16.11.8 on the TIMSK1 seems to me to be saying that you can use either A or B independent of one another.

Econjack, thanks, that's what I was looking for. I just hadn't slogged far enough through the text.

Dr. Quark