1

I have some code that relies on the input capture timer value.

I assume the timer value (as defined by the pre-scaler etc) is not affected by other code running i.e. it is updated every nth clock regardless of what instruction is next?

If you want code or more detail ask in comments and I will post code.

2 Answers 2

1

The way IC typically works is completely independent from the CPU and what instructions you are running.

The timer runs freely between the start and end input capture events. At the moment of capture the timer value is frozen into another register. The interrupt is then triggered. You then read that frozen value. It doesn't matter how long after the end event the interrupt executes, or what you do in that interrupt, the captured time is still the same.

2
  • Hello @Majenko - thanksfor answer. A quick one though. What happens if during the interrupt the interrupt is fired again faster than the code can run i.e. still responding to the interrupt when interrupt is fired again? I assume it is over-written and we have a loss of data? Commented Feb 26, 2017 at 12:16
  • The interrupt cannot trigger while it is current triggered. The CPU disables interrupts when it enters an interrupt and enables them afterwards. Any events that occur while the interrupt is running will be ignored. Commented Feb 26, 2017 at 12:19
0

I assume the timer value (as defined by the pre-scaler etc) is not affected by other code running i.e. it is updated every nth clock regardless of what instruction is next?

yes, unless your code writes to the registers involved.

2
  • Aren't there any higher priority Interrupts? They would certainly affect the timer register Commented Feb 19, 2017 at 6:28
  • @cyberponk No, registering input capture time works via dedicated hardware, idependent of what the CPU is doing. Commented Feb 19, 2017 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.