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.

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.

  • 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? – Paul Sullivan Feb 26 '17 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. – Majenko Feb 26 '17 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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.