Can I trigger Timer1 interrupts CAPT_vect and COMP_vect in the same code

hi guys

Is it possible to trigger CAPT_vect and COMP_vect interrupts with TIMER1 in the same code?

I have an idea of triggering ISR(TIMER1_CAPTA_vect) every time my Arduino identifies one spike in pin8 and store this value of ICR1 inside an array.

Then, after getting this value I need to add a number to it coming from the serial communication between a Python program and Arduino and assign this sum to OCR1A.

After OCR1A is reached, I call ISR(TIMER1_COMPA_vect) to generate a squared pulse of 60us.

Observations:

1-can I adjust a register inside an ISR function or I must do all the setting on setup()?

2- After my OCR1A is reached, to have my pulse width, can I update OCR1A value inside ISR(...COMPA..) and keep in it until the width is done?

3-In order to trigger ISR(...COMPA...) , can I set OCR1A values inside ISR(...CAPTA...)?

is this the kind of what you are trying to do?

http://www.avrprojects.net/index.php/avr-learn/getting-started-with-avr/51-programming-the-timer-counter-1?showall=1

hope that helps

Seriously? This is exactly what the code I gave you here does.

Then, you re-posted that same code in another thread.

Now, you've started yet another thread on the same topic. Why?

I was just wondering about them and their functionalities. I am currently thinking about another solution not involving FIFO, because of that fact we mentioned befores, regarding the amount of data that is being inserted vs taking out.

@gfvalvo when you wrote

risingEdgeTime = timeStamp + delayPeriod

this line wouldnt modify the actual delay I want ? For example, if my timeStamp is 3400 and I want 1s delay (=15625), my OCR1A is not being assigned with just the delay, but a value greater than it.

If it’s 3:00 now and you want your alarm to go off in 2 hours, do you set the alarm time for 2:00 or 5:00?